Python 3.x 如何更改输出的数据类型

Python 3.x 如何更改输出的数据类型,python-3.x,pandas,numpy,Python 3.x,Pandas,Numpy,我希望此代码的输出为int64格式,但此代码的输出为浮点格式。如何改变它?请建议 import pandas as pd import numpy as np df = pd.read_csv('https://query.data.world/s/HqjNNadqEnwSq1qnoV_JqyRJkc7o6O') df = df[df.isnull().sum(axis=1) < 5] print(round(100*(df.isnull().sum()/len(df.index))),2

我希望此代码的输出为int64格式,但此代码的输出为浮点格式。如何改变它?请建议

import pandas as pd
import numpy as np
df = pd.read_csv('https://query.data.world/s/HqjNNadqEnwSq1qnoV_JqyRJkc7o6O')
df = df[df.isnull().sum(axis=1) < 5]
print(round(100*(df.isnull().sum()/len(df.index))),2)
将熊猫作为pd导入
将numpy作为np导入
df=pd.read\u csv('https://query.data.world/s/HqjNNadqEnwSq1qnoV_JqyRJkc7o6O')
df=df[df.isnull().sum(轴=1)<5]
打印(圆形(100*(df.isnull().sum()/len(df.index))),2)

像这样的东西应该可以解决这个问题

import pandas as pd
import numpy as np

df = pd.read_csv('https://query.data.world/s/HqjNNadqEnwSq1qnoV_JqyRJkc7o6O')
df = df[df.isnull().sum(axis=1) < 5]

x = round(100*(df.isnull().sum()/len(df.index)))
y = x.astype(np.int64)

print(y)
将熊猫作为pd导入
将numpy作为np导入
df=pd.read\u csv('https://query.data.world/s/HqjNNadqEnwSq1qnoV_JqyRJkc7o6O')
df=df[df.isnull().sum(轴=1)<5]
x=四舍五入(100*(df.isnull().sum()/len(df.index)))
y=x.aType(np.int64)
打印(y)

关键位是x.astype(np.int64)以转换格式。

类似的内容应该可以实现这一点

import pandas as pd
import numpy as np

df = pd.read_csv('https://query.data.world/s/HqjNNadqEnwSq1qnoV_JqyRJkc7o6O')
df = df[df.isnull().sum(axis=1) < 5]

x = round(100*(df.isnull().sum()/len(df.index)))
y = x.astype(np.int64)

print(y)
将熊猫作为pd导入
将numpy作为np导入
df=pd.read\u csv('https://query.data.world/s/HqjNNadqEnwSq1qnoV_JqyRJkc7o6O')
df=df[df.isnull().sum(轴=1)<5]
x=四舍五入(100*(df.isnull().sum()/len(df.index)))
y=x.aType(np.int64)
打印(y)
密钥位为x.astype(np.int64)以转换格式。

df=df.astype(np.int64)
df=df.astype(np.int64)