-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Formatting of pandas expressions suboptimal for readability #662
Comments
This seems related to #571 - I'll +1 this as something that seems kind of bizarre. |
black won't reformat this unless your line is >
88 isn't much, I prefer 120. None the less, I'd also do the refactoring. This way you can provide more descriptive code. I'm certain you can find better names for Long lines with lots of in-line code and logic really aren't that great for readability... |
"One of the hardest things in programming is naming things" - and especially intermediate results in pandas transform chains, that's why you are going to have a hard time convincing pandas power users to adopt the unusual style you propose. I am going to disagree and say that chained method calls can be great for readability if formatted correctly. Changing line length would be a workaround for this specific example, but I don't believe it solves the underlying issue. |
Let's keep the discussion in #571 |
Arguing with the formatting decisions of black may be besides the point, but I am pretty happy with it with the exception of one type of expressions:
This is a typical
pandas
expression where some method calls are chained and fields of the dataframe are selected. Black seems to treat the field selection as a list and indents it on a new line. I think this is counterintuitive and does not improve readability. Is it intentional or a potential enhancement to treat this differently?Operating system: macOS
Python version: 3.7.0
Black version: '18.9b0'
The text was updated successfully, but these errors were encountered: