python 科学计算 panda使用matplot

2019-08-19  本文已影响0人  Mr洋1
1
https://www.csdojo.io/data 下载数据集 下载
x = [1,2,3]
y = [1,4,9]
plt.plot(x,y)
plt.title('test plot')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
test
x = [1,2,3]
y = [1,4,9]
z = [10,5,0]
plt.plot(x,y)
plt.plot(x,z)
plt.title('test plot')
plt.xlabel('x')
plt.ylabel('y and z')

plt.show()
2
x = [1,2,3]
y = [1,4,9]
z = [10,5,0]
plt.plot(x,y)
plt.plot(x,z)
plt.title('test plot')
plt.xlabel('x')
plt.ylabel('y and z')
plt.legend(["this is y","this is z"])
plt.show()
3
sample_data = pd.read_csv("sample_data.csv")
引入

indice :指数 index:索引

type(sample_data)
1

retrive 取出 underscore 下划线

sample_data.column_c
3 type
sample_data.column_c.iloc[1] #取出来第二个参数
iloc
1

x-axis y-axis x轴与y轴

plt.plot(sample_data.column_a,sample_data.column_b)
plt.show()

plot
plt.plot(sample_data.column_a,sample_data.column_b)
plt.plot(sample_data.column_a,sample_data.column_c)
plt.title('column')
plt.xlabel('a')
plt.ylabel('b and c')
plt.legend(['b','c'])
plt.show()
data.csv

bunch of 一大堆

data = pd.read_csv('countries.csv')
data

另外一个表格的对比

us_population = data[data.country=='United States']
us
ch_population = data[data.country == 'China']
china
plt.plot(us_population.year,us.population.population)
plt.show()
us
plt.plot(ch_population.year,ch_population.population)
plt.show()
ch 对比
上一篇下一篇

猜你喜欢

热点阅读