Skip to content
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

change the index in DataFrame.to_csv to False as default? #46583

Closed
KirderfEman opened this issue Mar 31, 2022 · 5 comments
Closed

change the index in DataFrame.to_csv to False as default? #46583

KirderfEman opened this issue Mar 31, 2022 · 5 comments
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@KirderfEman
Copy link

Maybe it’s time in some future release change the index in DataFrame.to_csv to False as default? Just a feeling that many change it manually from True to False every time using it...

Thanks for a 10/10 product!

@KirderfEman KirderfEman added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 31, 2022
@attack68
Copy link
Contributor

attack68 commented Apr 1, 2022

i suspect this is a widely used method. changing might cause more problems that the observed benefits. not convinced that a default of false is more readily used than true across all users and cases.

@KirderfEman
Copy link
Author

Ok, have only seen False in all codes I have seen in 4y, have also seen in examples/how-to that they recommend False. Hope you can take in consideration to future releases, changes in the standard parameters is common, I think the community can handle it.

@twoertwein
Copy link
Member

The same issue has previously been closed #12627 (very similar issue #24468)

@asishm
Copy link
Contributor

asishm commented Apr 3, 2022

Most of the code I've seen (within our org) either drops the "Unnamed ..." index column as the very first thing when reading a csv output by pd.DataFrame.to_csv or uses index=False when writing the csv.

The few times it is useful (when writing the result of a pivot / groupby operation directly without resetting the index) is a minority.

That said, and as much as I'd like to see the default being changed - it's unlikely to change (#34576 in addition to the ones listed above)

@mroeschke
Copy link
Member

Thanks for raising the issue, but additionally the core sticking point is that the Index is assumed a necessary component of a pandas DataFrame (for better or worse), so if the index (or axes in general) would ever be made optional this change would be more welcome. Closing for now as discussed in the linked issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

5 participants