相关疑难解决方法(0)

减少绘图滴答数

我的图表上有太多的刻度线,它们相互碰撞.

如何减少蜱的数量?

例如,我有蜱:

1E-6, 1E-5, 1E-4, ... 1E6, 1E7
Run Code Online (Sandbox Code Playgroud)

我只想要:

1E-5, 1E-3, ... 1E5, 1E7
Run Code Online (Sandbox Code Playgroud)

我已经尝试过了LogLocator,但是我还没弄清楚这一点.

python matplotlib

137
推荐指数
7
解决办法
14万
查看次数

pivot_table无需聚合的数字类型

我想从与列下面的数据帧进行透视表sales,rep.数据透视表显示sales但没有rep.当我只尝试时rep,我得到了错误DataError: No numeric types to aggregate.如何解决这个问题,我看到数字字段sales和字段(字符串)rep

data = {'year': ['2016', '2016', '2015', '2014', '2013'],
        'country':['uk', 'usa', 'fr','fr','uk'],
        'sales': [10, 21, 20, 10,12],
        'rep': ['john', 'john', 'claire', 'kyle','kyle']
        }

print pd.DataFrame(data).pivot_table(index='country', columns='year', values=['rep','sales'])

        sales               
year     2013 2014 2015 2016
country                     
fr        NaN   10   20  NaN
uk         12  NaN  NaN   10
usa       NaN  NaN  NaN   21


print pd.DataFrame(data).pivot_table(index='country', columns='year', values=['rep'])
DataError: No numeric types to aggregate
Run Code Online (Sandbox Code Playgroud)

python pandas

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×2

matplotlib ×1

pandas ×1