栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

分割大熊猫数据框

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

分割大熊猫数据框

用途

np.array_split

Docstring:Split an array into multiple sub-arrays.Please refer to the ``split`` documentation.  The only differencebetween these functions is that ``array_split`` allows`indices_or_sections` to be an integer that does *not* equallydivide the axis.

In [1]: import pandas as pdIn [2]: df = pd.Dataframe({'A' : ['foo', 'bar', 'foo', 'bar',   ...:     'foo', 'bar', 'foo', 'foo'],   ...:         'B' : ['one', 'one', 'two', 'three',   ...:     'two', 'two', 'one', 'three'],   ...:         'C' : randn(8), 'D' : randn(8)})In [3]: print df     A      B         C         D0  foo    one -0.174067 -0.6085791  bar    one -0.860386 -1.2105182  foo    two  0.614102  1.6898373  bar  three -0.284792 -1.0711604  foo    two  0.843610  0.8037125  bar    two -1.514722  0.8708616  foo    one  0.131529 -0.9681517  foo  three -1.002946 -0.257468In [4]: import numpy as npIn [5]: np.array_split(df, 3)Out[5]: [     A    B         C         D0  foo  one -0.174067 -0.6085791  bar  one -0.860386 -1.2105182  foo  two  0.614102  1.689837,      A      B         C         D3  bar  three -0.284792 -1.0711604  foo    two  0.843610  0.8037125  bar    two -1.514722  0.870861,      A      B         C         D6  foo    one  0.131529 -0.9681517  foo  three -1.002946 -0.257468]


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/645424.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号