0

I have a list of dataframes as:

[df1, df2, df3, ..., df100, oddDF]

Each dataframe dfi has DateTime as column1 and Temperature as column2. Except the dataframe oddDF which has DateTime as column1 and has temperature columns in column2 and column3.

I am looking to create a list of dataframe or one dataframe which has the common temperatures from each of df1, .. df100 and oddDF

I am trying the following:

dfs = [df0, df1, df2, .., df100, oddDF]
df_final = reduce(lambda left,right: pd.merge(left,right,on='DateTime'), dfs)

But it produces df_final as empty

If however I do just:

dfs = [df0, df1, df2, .., df100]
df_final = reduce(lambda left,right: pd.merge(left,right,on='DateTime'), dfs)

df_final produces the right answer.

How do I incorporate oddDF in the code also. I have checked to make sure that oddDF's DateTime column has the common dates with

df1, df2, .., df100
Zanam
  • 4,607
  • 13
  • 67
  • 143
  • looks ok to me ... can you try doing it in two steps, ie. merge the 100 df's then do a separate merge of the final one? this might help you find the problem – maxymoo Nov 11 '16 at 00:06
  • It gives NAN is I split the process. I don't have a clue. – Zanam Nov 11 '16 at 03:33
  • so the problem is really about merging two dataframes, not merging a list of dataframes. can you find a minimal subset of these two dataframes that reproduces the problem and include it in the question? – maxymoo Nov 11 '16 at 04:08

0 Answers0