Answers for "how to separate date and time in python"

0

how to separate date and time in python

import pandas as pd
df = pd.DataFrame({'datetime':pd.date_range('2020-01-01 07:10',periods=6)})
print("DataFrame is:\n", df)
df['date'] = pd.to_datetime(df['datetime']).dt.date
df['time'] = pd.to_datetime(df['datetime']).dt.time
print("Date-time-hour-minutes :\n", df)
Posted by: Guest on August-24-2021
0

how to separate date and time in python

for d in df['datetime']:
   df['date'] = d.date()
   df['time'] = d.time()
Posted by: Guest on August-24-2021

Code answers related to "how to separate date and time in python"

Python Answers by Framework

Browse Popular Code Answers by Language