You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
A pattern that has repeatedly caught me out is stringing operations together like: df['myfield'].notnull().unique() .. the error here is that notnull() returns a mask rather than a slice of the dataframe or series. Having most operations return a dataframe/series with the same signature, and ones that don't being more obvious, would probably ease the learning curve and help to avoid some user code errors, eg: df['myfield'].notnull() # returns a series of same dtype as df['myfield'], with the N/A rows dropped df['myfield'].is_notnull() # returns a series of dtype boolean to use as a mask
"monad-ish" because operations generally return an object of the same type.
This would unfortunately cause hard-to-find-in-user-code changes to the API
The text was updated successfully, but these errors were encountered:
having just hit "submit", I realized that using dropna() in this case is better than messing around with notnull() and making a mask .. but I still think a strong signal in method names for when the return type is not the same as the input type, is valuable
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
A pattern that has repeatedly caught me out is stringing operations together like:
df['myfield'].notnull().unique()
.. the error here is thatnotnull()
returns a mask rather than a slice of the dataframe or series. Having most operations return a dataframe/series with the same signature, and ones that don't being more obvious, would probably ease the learning curve and help to avoid some user code errors, eg:df['myfield'].notnull() # returns a series of same dtype as df['myfield'], with the N/A rows dropped
df['myfield'].is_notnull() # returns a series of dtype boolean to use as a mask
"monad-ish" because operations generally return an object of the same type.
This would unfortunately cause hard-to-find-in-user-code changes to the API
The text was updated successfully, but these errors were encountered: