教授给出的指令: 1.使用来自World Atlas数据的continent国家列表,将countries.csv文件加载到pandas DataFrame中,并将该数据集命名为国家。 2.使用Gapminder上提供的数据,将每人的收入(GDP /人均,PPP $通货膨胀调整后)作为熊猫数据框载入,并将此数据集命名为收入。 3.将数据集转换为以行和国家作为列的年份。加载时显示该数据集的头部。 4.以图形方式显示任何特定年份(例如2000年)世界各国人均收入分布情况。什么样的情节最好?从Pandas中的一行中获取数据
在下面的代码中,我完成了其中一些任务,但我很难理解如何从DataFrame行获取数据。我希望能够从一行中获取数据,然后绘制它。这可能看起来像一个微不足道的概念,但我已经有一段时间了,需要帮助。
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
countries = pd.read_csv('2014_data/countries.csv')
countries.head(n=3)
income = pd.read_excel('indicator gapminder gdp_per_capita_ppp.xlsx')
income = income.T
def graph_per_year(year):
stryear = str(year)
dfList = income[stryear].tolist()
graph_per_year(1801)
http://pandas.pydata.org/pandas-docs/stable/indexing.html –
您可以向我们展示'countries.head()'和'income.head()'的输出以供说明吗? – tipanverella