Answers for "how to transform int in float dataframe"

1

convert dataframe to float

df["data"] = df["data"].astype(float)
Posted by: Guest on July-25-2021
1

convert float to integer pandas

>>> df
          A         B     C         D
0  0.475103  0.355453  0.66  0.869336
1  0.260395  0.200287   NaN  0.617024
2  0.517692  0.735613  0.18  0.657106
>>> df[list("ABCD")] = df[list("ABCD")].fillna(0.0).astype(int)
>>> df
   A  B  C  D
0  0  0  0  0
1  0  0  0  0
2  0  0  0  0
Posted by: Guest on August-03-2020

Code answers related to "how to transform int in float dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language