Answers for "how to turn a number into a date pandas"

1

column of type int to date pandas

df['DataFrame Column'] = pd.to_datetime(df['DataFrame Column'], format=specify your format)

#Example
import pandas as pd

values = {'dates':  [20190902,20190913,20190921],
          'status': ['Opened','Opened','Closed']
          }

df = pd.DataFrame(values, columns = ['dates','status'])

df['dates'] = pd.to_datetime(df['dates'], format='%Y%m%d')

print (df)
print (df.dtypes)
Posted by: Guest on August-03-2021
0

convert a number column into datetime pandas

# convert the 'Date' column to datetime format
df['Date']= pd.to_datetime(df['Date'])
 
# Check the format of 'Date' column
df.info()
Posted by: Guest on January-14-2021

Code answers related to "how to turn a number into a date pandas"

Python Answers by Framework

Browse Popular Code Answers by Language