7 kyu
Pandas Series 103: Filter Rows From DataFrames That Don't Satisfy Condition
791albertogcmr
Loading description...
Data Frames
Fundamentals
Data Science
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
The initial solution given raises a NameError (
df
in the column check vsdataframe
in the parameter list).Fork rectifying this: https://www.codewars.com/kumite/666a794ebccbd79f03486250
Approved
Who votes 2 kyu here, this can't be in good faith :/
This kata does not describe how to handle cases where the target column does not exist in the DataFrame. Adding a check for the presence of a column and an associated error message would improve the feature.
Overall, the challenge provides a good starting point for practicing working with the pandas library and filtering data in a DataFrame, but some additional detail and testing could make it more complete.
I would def be more clear in the description on what you want for the user. I had to check the expected output to understand what you were going for. But all in all great kata!
A couple small suggestions for description clarity:
pandas.DataFrame
object with same data and columns than the original input. Only the rows whose cell values in designated column after the filter are evaluated asFalse
should appear in the result." -> Your function must return a newpandas.DataFrame
object with the same columns as the original input. However, include only the rows whose cell values in the designated column evaluate toFalse
byfunc
."Suggestion accepted! Thank you
By the way, I was really happy to see you making a Pandas series! I've been disappointed by how few Pandas katas there are.
The functions passed in the random tests is like this:
which is completely against the idiomatic practice in pandas. (In fact this causes the idiomatic practice fail the random tests.)
pandas
uses|
and&
in place ofor
andand
.Done.
x < a | b < x
- this is wrong. Anda < x < b
doesn't follow the pandas practice too.Fixed.
Now I see what it meant. Thank you very much
Same damn issue. Could you learn how to write tests before authoring these?
something like this?
Yes, but you probably should also compare
dtype
's to make it easier for the users.Thanks. Now I think it is done.
It'd be good if you designated somehow what is being tested. And IMO the dataframes should be compared only if the
dtype
test passed.It'd be good if you designated somehow what is being tested i don't undestand this.
Fixed.
While these improvements are a good step above no error message, using
pd.testing.assert_frame_equal
might give better results still since it covers errors on every possible dimension with corresponding pretty prints and messages.It could be a good idea. @FArekkusu has given pretty good feedback and has more experience that me in kata creation.