Skip to content

DOC: delim_whitespace deprecation warning advocates code that generates a warning in Python 3.12 #58487

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

Closed
1 task done
edbennett opened this issue Apr 30, 2024 · 2 comments
Closed
1 task done
Labels
Closing Candidate May be closeable, needs more eyeballs Docs

Comments

@edbennett
Copy link

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

pandas.read_csv and https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html

Documentation problem

The deprecation warning for the delim_whitespace option suggests using sep="\s+" instead. Since \s is not a valid escape sequence, in Python 3.11 and earlier this is equivalent to sep=r"\s+".

However, in Python 3.12, invalid escape sequences now generate SyntaxWarnings. I would suggest that Pandas should avoid advising users to add code that will generate warnings (in particular when doing so via a warning—if the suggestion is implemented, then the number of warnings would remain constant rather than decreasing)

Suggested fix for documentation

Replace all instances of sep="\s+" with either sep=r"\s+" or sep="\\s+".

@edbennett edbennett added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 30, 2024
@Aloqeely
Copy link
Member

Similar to what I said in #58488, not sure if this is worth fixing considering there's already a PR working on removing this parameter in #58280
We could fix this and backport it to the current docs, but I'm not sure if that's really necessary

@edbennett
Copy link
Author

Ah, I hadn't realised that removing the parameter entirely was so imminent. I agree that it's probably not worth backporting documentation changes for this.

@Aloqeely Aloqeely added Closing Candidate May be closeable, needs more eyeballs and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closing Candidate May be closeable, needs more eyeballs Docs
Projects
None yet
Development

No branches or pull requests

2 participants