PassengerId Survived Pclass Name \ 630 631 1 1 Barkworth, Mr. Algernon Henry Wilson 851 852 0 3 Svensson, Mr. Johan 493 494 0 1 Artagaveytia, Mr. Ramon Sex Age SibSp Parch Ticket Fare Cabin Embarked 630 male 80.0 0 0 27042 30.0000 A23 S 851 male 74.0 0 0 347060 7.7750 NaN S 493 male 71.0 0 0 PC 17609 49.5042 NaN C
age_num.reset_index(drop=True) #将上数结果重新编号
PassengerId
Survived
Pclass
Name
Sex
Age
SibSp
Parch
Ticket
Fare
Cabin
Embarked
0
631
1
1
Barkworth, Mr. Algernon Henry Wilson
male
80.0
0
0
27042
30.0000
A23
S
1
852
0
3
Svensson, Mr. Johan
male
74.0
0
0
347060
7.7750
NaN
S
2
494
0
1
Artagaveytia, Mr. Ramon
male
71.0
0
0
PC 17609
49.5042
NaN
C
age_num.iloc[1]#取出这一行的数据
PassengerId 852
Survived 0
Pclass 3
Name Svensson, Mr. Johan
Sex male
Age 74
SibSp 0
Parch 0
Ticket 347060
Fare 7.775
Cabin NaN
Embarked S
Name: 851, dtype: object
import pandas as pdimport numpy as npfood_info = pd.read_csv("D:\\test\\titanic_train.csv") #此处需要转义food_info.head(2) PassengerId Survived Pclass Name Sex