0

Two Dataframes:

df1:

 zone_temp_1 Date/Time 15:36:20 73.500000 15:36:40 73.500000 15:37:00 73.400002 15:37:20 73.400002 15:37:40 73.400002 15:38:00 73.400002 15:38:20 73.500000 

df2:

 zone_temp_1 Date/Time 15:38:40 73.500000 15:39:00 73.400002 15:39:20 73.400002 15:39:40 73.400002 15:40:00 73.400002 

I would like the concatenation to look like this:

 zone_temp_1 Date/Time 15:36:20 73.500000 15:36:40 73.500000 15:37:00 73.400002 15:37:20 73.400002 15:37:40 73.400002 15:38:00 73.400002 15:38:20 73.400002 15:39:20 73.500000 15:39:40 73.500000 15:40:00 73.400002 

Using pandas.concat as such "df1= pd.concat([df1, df2])" leaves me with this

 0 zone_temp_1 Date/Time 15:36:20 73.500000 NaN 15:36:40 73.500000 NaN 15:37:00 73.400002 NaN 15:37:20 73.400002 NaN 15:37:40 73.400002 NaN 15:38:00 73.400002 NaN 15:38:20 73.400002 NaN 15:38:40 NaN 73.500000 15:38:20 NaN 73.500000 15:39:00 NaN 73.400002 15:39:20 NaN 73.400002 15:39:40 NaN 73.400002 15:40:00 NaN 73.400002 

This was marked as a repeat question but I have done my due diligence and can not find any solution.

8
  • @W-B I read through that and did not see the answer to my case explicitly. Care to elaborate? PS: Love the profile pic Commented Dec 11, 2018 at 21:03
  • Make sure both of the dataframe you are testing same as what you show to us , pd.concat will match the columns and index (depends on axis=0 or axis=1) Commented Dec 11, 2018 at 21:33
  • @W-B I updated it to replicate my EXACT data and results. I am not sure how to edit it to look pretty though. Commented Dec 11, 2018 at 21:41
  • df1= pd.concat([df1.rename(columns={0:'zone_temp_1'), df2]) Commented Dec 11, 2018 at 21:43
  • @W-B Are you suggesting I replace the "df1= pd.concat([df1, df2])" with that snippet? That would not work as I do not get that '0' column until I attempt concatenate the first time. Commented Dec 11, 2018 at 21:51

1 Answer 1

0

You can do bigdata = df1.append(df2, ignore_index=True)

Sign up to request clarification or add additional context in comments.

1 Comment

Nope, same issue as up top except it removes my 'Date/Time' index

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.