First off, my data set is shown below
What I'd like to do is group my columns by pickup_datetime
hour. I've found related questions on here but for some reason the solution doesn't seem to work. I've included my attemps below.
I first started off with this:
df["dropoff_datetime"] = pd.to_datetime(df["dropoff_datetime"])
df["pickup_datetime"] = pd.to_datetime(df["pickup_datetime"])
test = df.groupby(df.hour).sum()
And I got the following error:
AttributeError: 'DataFrame' object has no attribute 'hour'
Then I tried this:
test = df.groupby(df.dropoff_datetime.hour).sum()
And I got the following error:
AttributeError: 'Series' object has no attribute 'hour'
I'm a bit confused because it seems like my situation is the same as the question linked above. I'm not sure why I am getting errors though. Any help would be much appreciated