xxxxxxxxxx
print(df['column']) # datetime column exemple
# Name: column, dtype: datetime64[ns]
df['column'] = df['column'].apply(lambda value: str(value)) # for each column value convert to string
print(df['column'])
# Name: column, dtype: object
# Change "column" to your column
xxxxxxxxxx
# Convert "Fee" from int to string
df = df.astype({'colomnName':'string'})
print(df.dtypes)
xxxxxxxxxx
import pandas as pd
# Assuming you have a DataFrame called 'df' with a column named 'column_name'
df['column_name'] = df['column_name'].astype(str)
xxxxxxxxxx
# column names which need to be string
lst_str_cols = ['prefix', 'serial']
dict_dtypes = {x: 'str' for x in lst_str_cols}
pd.read_csv('sample.csv', dtype=dict_dtypes)