Reputation: 35
I have a dataframe called: twitter_df with two columns, tweets and date columns. For every tweet there is a datetime entry like below:
Date
2019-11-29 12:50:54
2019-11-29 12:46:53
2019-11-29 12:46:10
2019-11-29 12:33:36
2019-11-29 12:17:43
I would like the entries for Date column to be this:
Date
2019-11-29
2019-11-29
2019-11-29
2019-11-29
2019-11-29
The reason I want the HH:MM:SS to be removed is because I am going to group it by the date.
I have tried several links but no luck on my end, can anyone assist? Some say I should make use of pd.to_datetime but not sure how i should go about.
Upvotes: 1
Views: 3228
Reputation: 9857
This will create a new column, onlyDate, with only the date from the Date column.
If you want to replace the existing column change 'onlyDate' to 'Date' on the left hand side.
twitter_df['onlyDate'] = twitter_df['Date].dt.date
Upvotes: 2