大Pandas数据帧改造

2024-10-16 22:26:17 发布

您现在位置:Python中文网/ 问答频道 /正文

伙计们,我正在学习。 我从联合国数据中心下载了一个.csv文件来学习。你知道吗

http://data.un.org/Data.aspx?q=gdp&d=SNAAMA&f=grID%3a101%3bcurrID%3aUSD%3bpcFlag%3a1

然而,这个CSV文件的形式不是我所期望的。 它看起来像下面。你知道吗

Country or Area Year    Item    Value

0   Afghanistan 2016    Gross Domestic Product (GDP)    583.882867

1   Afghanistan 2015    Gross Domestic Product (GDP)    610.854517

2   Afghanistan 2014    Gross Domestic Product (GDP)    651.158326

3   Afghanistan 2013    Gross Domestic Product (GDP)    681.033974

4   Afghanistan 2012    Gross Domestic Product (GDP)    694.885886


...

9441    Zimbabwe    1974    Gross Domestic Product (GDP)    721.921573

9442    Zimbabwe    1973    Gross Domestic Product (GDP)    620.261471

9443    Zimbabwe    1972    Gross Domestic Product (GDP)    521.701845

9444    Zimbabwe    1971    Gross Domestic Product (GDP)    437.030171

9445    Zimbabwe    1970    Gross Domestic Product (GDP)    390.776187

我想把每个国家的数据排成一行,年份排在名称栏。你知道吗

有什么办法吗?你知道吗


Tags: 文件csvorghttpdataproduct数据中心un