I have a pandas data frame which looks like this
Data Source World Development Indicators Unnamed: 2 Unnamed: 3 Unnamed: 4 Unnamed: 5
Country Name Country Code Indicator Name Indicator Code 1.960000e+03 1.961000e+03
Aruba ABW GDP at market prices (constant 2010 US$) NY.GDP.MKTP.KD NaN NaN
为将第一行转换为其列,我使用以下代码:
data.columns = data.iloc[0]
结果数据框被修改为:
Country Name Country Code Indicator Name Indicator Code 1960.0 1961.0 1962.0
Country Name Country Code Indicator Name Indicator Code 1.960000e+03 1.961000e+03
Aruba ABW GDP at market prices (constant 2010 US$) NY.GDP.MKTP.KD NaN NaN
现在我的主要问题是对于以年份为标题的列,我得到的是1960.0,而我想得到一个整数即1960。如果有帮助,将不胜感激。