Stack Overflow Asked by Suhas_mudam on November 22, 2021
I have a dataframe containing the column ‘Date’ with value as ‘9999-12-31 00:00:00’. I need to convert it to ‘dd/mm/yyyy’.
import pandas as pd
data = (['9999-12-31 00:00:00'])
df = pd.DataFrame(data, columns=['Date'])
Use daily periods by custom function with remove times by split
and change format by strftime
:
df['Date'] = (df['Date'].str.split()
.str[0]
.apply(lambda x: pd.Period(x, freq='D'))
.dt.strftime('%d/%m/%Y'))
print (df)
Date
0 31/12/9999
Answered by jezrael on November 22, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP