what would be possible issue?
I want to change datatype of columns in data frame
I have tried below codes only last one gives error all others are working but not changing datatype of columns even if below code is run datatype remains object for these columns.
#df[[‘articleID’,’sizeCode’,’productGroup’]].astype(int)
#df[‘rrp’].astype(float)
#changed datatypes of variables as required
“””df=df.astype({‘articleID’: int,
‘rrp’: float,’sizeCode’: int,
‘productGroup’: int,
})
“””
Below code gives Value Error: Columns must be same length as key
df[‘articleID’] = df.astype({‘articleID’: int})
Trupti Jadhav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.