基于本教程http://www.youtube.com/watch?v=aKs1Vgtb1do:
import pandas as pd
names1880 = pd.read_csv('yob1880.txt', names={'name', 'sex', 'births'})
names1880.head(10)
Out[34]:
births name sex
0 Mary F 7065
1 Anna F 2604
2 Emma F 2003
3 Elizabeth F 1939
4 Minnie F 1746
5 Margaret F 1578
6 Ida F 1472
7 Alice F 1414
8 Bertha F 1320
9 Sarah F 1288
ubuntu@ubuntu-VirtualBox:~/P4DA$ head yob1880.txt
Mary,F,7065
Anna,F,2604
Emma,F,2003
Elizabeth,F,1939
Minnie,F,1746
Margaret,F,1578
Ida,F,1472
Alice,F,1414
Bertha,F,1320
Sarah,F,1288
Question> 为什么列名顺序names1880.head(10)
不正确?
代码打印:
Out[34]:
births name sex
我预计:
Out[34]:
name sex births