I have a data frame with a column with dtype(int64)
and I want convert it to int32
.
when I run code below, I get dtype(int8)
type but i want get int32
pd.to_numeric(x, downcast="integer")
how do i do it!
CodePudding user response:
Try this,
df['col'].astype(np.int32)
astype doc link: https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.astype.html
Please have a look at numpy datatype docs: https://numpy.org/doc/stable/user/basics.types.html