I am having below data in pandas dataframe. Some date vales are repeating(2010-07-31,2010-10-31). Need to remove repeated dates and merge the values between two rows.
I have used the solution from the following question. But using below code sets Date column as Index. I don't want date column to be set as Index. Need help in removing duplicate dates and merging values of two rows in Pandas Dataframe (python)
Code:
df = df.groupby(['Date']).sum()
Dataframe df:
Index Date A B C D
1 2010-06-30 0:00:00 47.1 29.34 0.036 100.8
2 2010-07-31 0:00:00 47.1 29.34
3 2010-07-31 0:00:00 -4.644 100.2
4 2010-08-31 0:00:00 47.1 29.34 -1.481 100.4
5 2010-09-30 0:00:00 29.3 14.15 3.865 101.6
6 2010-10-31 0:00:00 29.3 14.15
7 2010-10-31 0:00:00 0.517 102.6
Expected output:
Index Date A B C D
1 2010-06-30 0:00:00 47.1 29.34 0.036 100.8
2 2010-07-31 0:00:00 47.1 29.34 -4.644 100.2
4 2010-08-31 0:00:00 47.1 29.34 -1.481 100.4
5 2010-09-30 0:00:00 29.3 14.15 3.865 101.6
6 2010-10-31 0:00:00 29.3 14.15 0.517 102.6
df.groupby(['Date'], as_index=False).sum()