-
Notifications
You must be signed in to change notification settings - Fork 18k
fix(histogram): add NULL handling for histogram #35693
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
Changes from 7 commits
2f23078
ccef6c9
50cfe80
49d7165
8e93aca
7e37e67
55b453f
af3615e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,11 @@ def histogram( | |
| if groupby is None: | ||
| groupby = [] | ||
|
|
||
| # drop empty values from the target column | ||
| df.dropna(subset=[column], inplace=True) | ||
|
janani-gurram marked this conversation as resolved.
Outdated
|
||
| if df.empty: | ||
| return df | ||
|
janani-gurram marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Input DataFrame modified in-place
Tell me moreWhat is the issue?The function modifies the input DataFrame in-place by dropping rows with NULLs, which violates the principle of not mutating input parameters and can cause unexpected side effects for the caller. Why this mattersCallers may not expect their original DataFrame to be modified, leading to data loss in the calling code and potential bugs in downstream processing that depends on the original DataFrame structure. Suggested change ∙ Feature PreviewCreate a copy of the DataFrame before dropping NULLs: # drop empty values from the target column
df = df.dropna(subset=[column])
if df.empty:
return dfProvide feedback to improve future suggestions💬 Looking for more details? Reply to this comment to chat with Korbit. |
||
|
|
||
| # convert to numeric, coercing errors to NaN | ||
| df[column] = to_numeric(df[column], errors="coerce") | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The comment says "drop empty values" but the code actually drops NULL/NaN values. Consider using more precise terminology: "Drop NULL values from the target column" to be clearer about what's being removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, but optional in my mind.