Answers for "pandas convert column from int to object TYPE"

3

column dataframe to int

df[[column_name]].astype(int)
Posted by: Guest on April-21-2021
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

Code answers related to "pandas convert column from int to object TYPE"

Python Answers by Framework

Browse Popular Code Answers by Language