本文为IPython下的md文件直接导入生成
import pandas as pd
import numpy as np
T_data
T_data.loc[T_data["Survived" ]==1 ,]
PassengerId Survived Pclass Name Sex Age A 2 1 1 Cumings, Mrs. John Bradley (Florence Briggs Th… female 38.0 B 3 1 3 Heikkinen, Miss. Laina female 26.0 C 4 1 1 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0 H 9 1 3 Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg) female 27.0 I 10 1 2 Nasser, Mrs. Nicholas (Adele Achem) female 14.0
Score={"Li Ming" :pd.Series([78 ,90 ,87 ]),
"Zhang Yan" :pd.Series([88 ,56 ,94 ]),
"Yin Hong" :pd.Series([92 ,85 ,93 ])}
Pd_Score=pd.DataFrame(Score)
Pd_Score.index=["Math" ,"Chinese" ,"English" ]
Pd_Score
Li Ming Yin Hong Zhang Yan Math 78 92 88 Chinese 90 85 56 English 87 93 94
bool_index=(Pd_Score.loc["Math" ]>80 )&(Pd_Score.loc["Chinese" ]>80 )&(Pd_Score.loc["English" ]>80 )
bool_index
Li Ming False Yin Hong True Zhang Yan False dtype: bool
Pd_Score.loc[:,bool_index]
Yin Hong Math 92 Chinese 85 English 93
Pd_Score.loc[:,(Pd_Score.iloc[0 ]>80 )&(Pd_Score.iloc[1 ]>80 )&(Pd_Score.iloc[2 ]>80 )]
Yin Hong Math 92 Chinese 85 English 93
Pd_Score
Li Ming Yin Hong Zhang Yan Math 78 92 88 Chinese 90 85 56 English 87 93 94
Pd_Score.ix[:,[1 ]]
Yin Hong Math 92 Chinese 85 English 93
Pd_Score.ix[0 :2 ,"Li Ming" ]
Math 78 Chinese 90 Name: Li Ming, dtype: int64
Pd_Score.ix[["Math" ],0 :2 ]