dateframe取数据

import numpy as np
import pandas as pd
#
# x1=[1,2,3,4]
# x2=[4,5,6,7]
# x3=[7,8,9,10]
# df=pd.DataFrame(
# { 'x1':x1,
# 'x2':x2,
# 'x3':x3
# }
# )
# print(df)
# print(df['x1'])
# print(type(df['x1']))#<class 'pandas.core.series.Series'>#不含列名
# print(df['x1'].values)
# print(type(df['x1'].values))#<class 'numpy.ndarray'>
# print(df[['x1']])
# print(type(df[['x1']]))#<class 'pandas.core.frame.DataFrame'>含有列名
# #无索引,有列名
# #loc取某一个数,
# print(df.loc[1,'x2'])#5
# print(df.loc[0:1,['x1','x3']])#DataFrame
#
# #无索引,列名长
# print(df.iloc[1,1])
# print(df.iloc[0:2,1:3])
#
# #ix函数
# print(df.ix[1,1])
# print(df.ix[1,'x2']) data = pd.DataFrame({'A':[1,2,3],'B':[4,5,6],'C':[7,8,9]},index=["a","b","c"])
print(data)
print(data.loc['a','B'])
print(data.loc['a':'c','A':'B'])
上一篇:android开发之-软件设置保存-快速学会使用SharedPreferences篇-实测


下一篇:Codeforces 1093 简要题解