Splitting timestamp column into separate date and time columns

Had same problem and this worked for me.

Suppose the date column in your dataset is called “date”

import pandas as pd
df = pd.read_csv(file_path)

df['Dates'] = pd.to_datetime(df['date']).dt.date
df['Time'] = pd.to_datetime(df['date']).dt.time

This will give you two columns “Dates” and “Time” with splited dates.

Leave a Comment