bogon:Documents rousseau$ ipython --pylab Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13) Type 'copyright', 'credits' or 'license'for more information IPython 6.2.1 -- An enhanced Interactive Python. Type '?'forhelp. Using matplotlib backend: MacOSX In [1]: import pandas as pd In [2]: import numpy as np In [3]: import matplotlib as plt In [4]: from pandas import Series, DataFrame
In [194]: df.sort_values(by='beijing') Out[194]: beijing guangzhou shanghai university 200150190 people 300020002800 area 500030002500
In [195]: df.sort_values(by='beijing',ascending=False) Out[195]: beijing guangzhou shanghai area 500030002500 people 300020002800 university 200150190
In [196]: df.sort_values(axis=1,by='people',ascending=False) Out[196]: beijing shanghai guangzhou area 500025003000 people 300028002000 university 200190150
统计操作
1 2 3 4 5 6 7 8 9 10 11 12
```python In [198]: df.T.describe() Out[198]: area people university count 3.000000 3.000000 3.000000 mean 3500.000000 2600.000000 180.000000 std 1322.875656 529.150262 26.457513 min 2500.000000 2000.000000 150.000000 25% 2750.000000 2400.000000 170.000000 50% 3000.000000 2800.000000 190.000000 75% 4000.000000 2900.000000 195.000000 max 5000.000000 3000.000000 200.000000