I have the following DF:
df = pd.DataFrame({'Date' : ['11/8/2011', '11/9/2011', '11/10/2011',
'11/11/2011', '11/12/2011', '','','','',''],
'Event' : ['Dance', 'Painting', 'Bowling', 'Rugby', 'Running','Dance', 'Painting', 'Bowling', 'Rugby', 'Running']})
df
I want to copy the value of "Date" that corresponds to the row of the specific "Event" value (from a non-blank to a blank location), if the "Event" values match. So, if 'Dance' is associated with the value '11/8/2011', I want all "Dance" to have those values under date, and not be blank.
I want the final DF to look like this:
df = pd.DataFrame({'Date' : ['11/8/2011', '11/9/2011', '11/10/2011',
'11/11/2011', '11/12/2011', '11/8/2011', '11/9/2011', '11/10/2011','11/11/2011', '11/12/2011'],
'Event' : ['Dance', 'Painting', 'Bowling', 'Rugby', 'Running','Dance', 'Painting', 'Bowling', 'Rugby', 'Running']})
I tried:
DF_New = df.groupby(['Event'])
But get the following message, instead of a new dataframe:
<pandas.core.groupby.generic.DataFrameGroupBy object at 0x7fe560cc17d0>