9951 explained code solutions for 126 technologies

python-pandasHow to convert timestamp to datetime

import pandas as pd

df = pd.DataFrame({
  'timestamp': ['1655977822', '1655977821', '1655977803'],
  'value': [1,2,3]

df['date'] = pd.to_datetime(df['timestamp'], unit='s')ctrl + c
import pandas as pd

load Pandas module


creates Pandas DataFrame object


convert given column values to datetime type (will automatically parse given strings)


needed to treat given value as unix timestamp


column with datetime type