longitude 39 latitude 116 temperature 26 dtype: int64
0 1 1 2 2 3 3 4 4 5 5 6 longitude 39 latitude 116 temperature 26 dtype: int64
longitude 39 latitude 116 dtype: int64
#DataFrame的创建与行列访问(表格型的数据结构)import pandas as pd
df = pd.DataFrame({'col1':[1,2,5,7],'col2':['a','b','c','d']})
df
col1
col2
0
1
a
1
2
b
2
5
c
3
7
d
#由列表组成的字典创建DataFrameimport pandas as pd
lista =[1,2,5,7]
listb =['a','b','c','d']
df = pd.DataFrame({'col1':lista,'col2':listb})
df
col1
col2
0
1
a
1
2
b
2
5
c
3
7
d
#修改DataFrame数据import numpy as np
import pandas as pd
data=pd.DataFrame(np.arange(16).reshape(4,4),index=['BJ','SH','GZ','SZ'],columns=['q','r','s','t'])
data['q']['BJ']=8
data['t']=8
data['s']['SZ']=8
data
#使用Pandas模块求方差import numpy as np
import pandas as pd
a = np.arange(0,60,5)
a = a.reshape(3,4)
df = pd.DataFrame(a)print(df)print('-------------')print(df.std())