1.代码
import pandas as pd
data=pd.read_csv('D:/anaconda/Affairs.csv')#括号里面的是文件的地址
print(data.head(10))
2.运行结果
Unnamed: 0 affairs gender age yearsmarried children religiousness \
0 4 0 male 37.0 10.00 no 3
1 5 0 female 27.0 4.00 no 4
2 11 0 female 32.0 15.00 yes 1
3 16 0 male 57.0 15.00 yes 5
4 23 0 male 22.0 0.75 no 2
5 29 0 female 32.0 1.50 no 2
6 44 0 female 22.0 0.75 no 2
7 45 0 male 57.0 15.00 yes 2
8 47 0 female 32.0 15.00 yes 4
9 49 0 male 22.0 1.50 no 4
education occupation rating
0 18 7 4
1 14 6 4
2 12 1 4
3 18 6 5
4 17 6 3
5 17 5 5
6 12 1 3
7 14 4 4
8 16 1 2
9 14 4 5
学号:202113430121 姓名:周金枝