Python Pivot表Python

时间:2016-12-06 03:46:25

标签: python-3.x pandas pivot data-analysis

我是熊猫和Python的新手。我有一个数据透视表,如:

grp3 = DataFrame(hrsub.pivot_table('left',index = 'sales',columns = 'sat_levels', aggfunc = 'count'))

输出:

sat_levels  
    low high

IT  199 74

RandD   85  36

accounting  161 43

hr  159 56

management  66  25

marketing   149 54

product_mng 129 69

sales   727 287

support 383 172

technical   492 205

我想通过

获取两列的比例
hrsub['low']/hrsub['high']

但它错误地说数据应该是1维的。我应该做什么呢?

1 个答案:

答案 0 :(得分:-2)

Python Pandas Pivot表:

 pandas.pivot_table(data, values=None, index=None, columns=None, aggfunc='mean',
                       fill_value=None, margins=False, dropna=True, margins_name='All')

https://pandas.pydata.org/pandas-docs/stable/generated/pandas.pivot_table.html