-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: add ignore_index argument to DataFrame.explode / Series.explode #34932
Comments
If this change looks oké by one of the devs, I can submit a PR for this. |
take |
I think something like this was discussed when |
I looked at the following discussions and couldn't find anything about resetting the index:
Not sure if I missed anything. @TomAugspurger |
Thanks for checking.
…On Mon, Jun 22, 2020 at 7:03 AM Erfan Nariman ***@***.***> wrote:
I looked at the following discussions and couldn't find anything about
resetting the index:
1. #16538 <#16538>
2. #10511 <#10511>
3. #27267 <#27267>
Not sure if I missed anything. @TomAugspurger
<https://github.com/TomAugspurger>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#34932 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKAOIULGOMPJDVR5X7QKE3RX5CCHANCNFSM4OEOKHFA>
.
|
it’s ok to add this argument (was added elsewhere after explode existed) |
What's the upside of adding this as an argument instead of just calling reset_index? |
Not sure if im in the position to comment on your question, but in terms of API design, isn't that in the line of other methods like |
Ah OK makes sense since we do elsewhere |
For the One aspect related to the index of the result that was briefly discussed in the original PR (#27267 (review)) is whether to add a level to the index with a "count", thus resulting in a MultiIndex (which could eg be useful if you want to do an unstack in a next step). I personally think that could still be useful, and we could potentially think about combining that in a single keyword. However, since |
When we use
DataFrame.explode
right now, it will repeat the index for each element in the iterator. To keep it consistent with the methods likeDataFrame.sort_values
,DataFrame.append
andpd.concat
, we can add an argumentignore_index
, which will reset the index.Expected behaviour with addition of the argument:
The text was updated successfully, but these errors were encountered: