User Tools

Site Tools


convert_a_dictionary_of_dataframes_to_a_big_dataframe

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
convert_a_dictionary_of_dataframes_to_a_big_dataframe [2022/03/18 23:29] – created rajuconvert_a_dictionary_of_dataframes_to_a_big_dataframe [2023/01/01 15:51] (current) – [Task] raju
Line 1: Line 1:
 ===== Convert a dictionary of dataframes to a big dataframe ===== ===== Convert a dictionary of dataframes to a big dataframe =====
 ==== Task ==== ==== Task ====
-Given a dictionary strings to dataframes, create an expanded dataframe by putting the keys into their own column. For example, given+Given a dictionary of strings to dataframes, create an expanded dataframe by putting the keys into their own column. For example, given
 <code> <code>
 {'COST':    fiscal_quarter_end  reported_date {'COST':    fiscal_quarter_end  reported_date
Line 86: Line 86:
  
 <code> <code>
 +In [4]:
 def dict_df_to_df(dict_df, key_col_name): def dict_df_to_df(dict_df, key_col_name):
     df = (     df = (
Line 172: Line 173:
 7   CPRT              202201       20220216 7   CPRT              202201       20220216
 </code> </code>
 +
 +==== Ref ====
 +  * https://stackoverflow.com/questions/56638413/how-to-create-a-pandas-dataframe-from-dictionary-of-dataframes - where I first came across this solution. I just put the solution in a function, used a better example and showed some intermediate steps on how the solution works.
convert_a_dictionary_of_dataframes_to_a_big_dataframe.1647646178.txt.gz · Last modified: 2022/03/18 23:29 by raju