I think you need to click on numpy.int64
:
df['column name'].astype(np.int64)
Example:
df = pd.DataFrame({'column name':[7500000.0,7500000.0]})
print (df['column name'])
0 7500000.0
1 7500000.0
Name: column name, dtype: float64
df['column name'] = df['column name'].astype(np.int64)
print (df['column name'])
0 7500000
1 7500000
Name: column name, dtype: int64
If some columns NaN
in the columns should replace them with int
(for example 0
) on fillna
, because type
of NaN
is float
:
df = pd.DataFrame({'column name':[7500000.0,np.nan]})
df['column name'] = df['column name'].fillna(0).astype(np.int64)
print (df['column name'])
0 7500000
1 0
Name: column name, dtype: int64
-
EDIT:
NaN
:
df = pd.DataFrame({'column name':[7500000.0,np.nan]})
df['column name'] = df['column name'].values.astype(np.int64)
print (df['column name'])
0 7500000
1 -9223372036854775808
Name: column name, dtype: int64