I want to extract the time part of a datetime column (2021-02-17 00:14:53). For example, from Twitter data stored in a dataframe. In this example the datetime dtype is stored in a column named date.
You must convert the column to a datetime using pd.to_datetime
and use Pandas dt
function to access the time portion of the datetime field.
df['time_only'] = pd.to_datetime(df['date'])
time_only = df['time_only'].dt.time
time_only