question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DOC: sample codes should not override Python built-in functions

See original GitHub issue

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

For example, https://pandas.pydata.org/pandas-docs/stable/user_guide/groupby.html#transformation

Alternatively, the built-in methods could be used to produce the same outputs.

max = ts.groupby(lambda x: x.year).transform("max")

min = ts.groupby(lambda x: x.year).transform("min")

max - min

Documentation problem

It is not good that the user guide lists codes that override Python built-in functions.

This is the only part I happened to find, but others may exist in doc. If so, its should be revised as well.

Suggested fix for documentation

In this case, max/min should rename like max_ts/min_ts.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
phoflcommented, Jul 8, 2022

I disagree with that. Having a variable named the same as the argument name associates them with each other in my opinion

0reactions
wany-ohcommented, Jul 8, 2022

Sorry, for the duplicate pull request. I didn’t know @wany-oh would take care of it, I just did it in case…

It was almost at the same time. Thank you for the follow up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Built-in Functions — Python 3.11.1 documentation
When converting from a string, the string must not contain whitespace around the central + or - operator. For example, complex('1+2j') is fine, ......
Read more >
Assigning to built-in function — Python Anti-Patterns ...
Unless you have a special reason, you should neither overwrite these functions nor assign a value to a variable that has the same...
Read more >
Operator and Function Overloading in Custom Python Classes
The special method corresponding to it is __iadd__() . The __iadd__() method should make changes directly to the self argument and return the...
Read more >
2. Built-in Functions — Python 2.7.2 documentation
The filename argument should give the file from which the code was read; ... If the object does not provide __dir__(), the function...
Read more >
Overriding a Built-In Method - Python Cookbook [Book] - O'Reilly
In most cases, overriding special methods of built-in objects when you inherit from those objects (or wrap them with automatic delegation, which is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found