Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas transform date format?

import pandas as pd

df = pd.DataFrame({'DOB': {0: '26/1/2016', 1: '26/1/2016'}})
print (df)
         DOB
0  26/1/2016 
1  26/1/2016

df['DOB'] = pd.to_datetime(df.DOB)
print (df)
         DOB
0 2016-01-26
1 2016-01-26

df['DOB1'] = df['DOB'].dt.strftime('%m/%d/%Y')
print (df)
         DOB        DOB1
0 2016-01-26  01/26/2016
1 2016-01-26  01/26/2016
Comment

PREVIOUS NEXT
Code Example
Python :: how to get seconds from datetime in python 
Python :: comment concatener deux listes python 
Python :: author nextcord interactions 
Python :: pd merge on multiple columns 
Python :: full screen jupyter notebook 
Python :: how to save bulk create in django 
Python :: Tkinter button icons 
Python :: selenium webdriver 
Python :: openpyxl xls 
Python :: swapcase 
Python :: Python terminal colour 
Python :: python number divisible by two other numbers 
Python :: accessing dictionary elements in python 
Python :: binary string to hex python 
Python :: filter dataframe 
Python :: two loop type python 
Python :: flask db migrate 
Python :: delete files with same extensions 
Python :: check nan values in a np array 
Python :: global keyword python 
Python :: __gt__ 
Python :: remove first 2 rows in pandas 
Python :: ipython on cmd 
Python :: label encoding 
Python :: Add new column based on condition on some other column in pandas. 
Python :: python class name 
Python :: pil image to numpy array 
Python :: stack overflow python timedate 
Python :: python count total no of word in a text 
Python :: python list abstraction 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =