[英]Index creation in pandas groupby
When I use groupby on a pandas dataframe, an index is automatically created by the column I used for grouping. 当我在熊猫数据帧上使用groupby时,我用于分组的列会自动创建一个索引。 If I want to use that column later, I can do something like:
如果以后要使用该列,可以执行以下操作:
df['index1'] = df.index
Is there a way, I can use groupby and not create the index? 有没有办法,我可以使用groupby而不创建索引? Specifying as_index=False does not work.
指定as_index = False无效。
Specify as_index=False
in the groupby call. 在groupby调用中指定
as_index=False
。 See the groupby docstring . 请参阅groupby docstring 。
(although it will depend on the exact operation you do on the groupby object afterwards if this will have effect or not). (尽管它是否生效取决于您随后对groupby对象执行的确切操作)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.