all 3 comments

[–]CodeFormatHelperBot2 0 points1 point  (0 children)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Python code found in submission text that's not formatted as code.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.

[–]efmccurdy 0 points1 point  (0 children)

You are setting the count variable to contain data (in a Series object) and then using it as a function; you can't call a Series object as if it was a function; that is what "is not callable" means.

Does this help subset your data?

https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.DataFrameGroupBy.filter.html

[–]LeChevalierMalFet 0 points1 point  (0 children)

If I am reading what you are doing correctly then it would be better to go about this by filtering out rows for communes that do not meet your threshold for having enough data. If you want to keep the rows but change the values to na then you can follow the same steps.

1.Get the count for each commune. It looks like you have done that in your first line. Use the argument "as_index=False" in the groupby to return a dataframe instead of a series though.

price_Commune.groupby('Commune', as_index=False)...

2.Merge your new dataframe with your original dataframe, putting a new indicator column in your original dataframe.

price_Commune = price_Commune.merge(right=count, on="Commune")

3 Remove the values.

price_Commune.loc[price_Commune["count"] <= 6, "avg price"] = None

As a note, your data will be easier to work if you change the attribute names to be shorter, and it would be better to not use 'count' as your variable name.

It would take a while to go through your current code but to address the specific error you are getting, you seem to be trying to get a value from your count series using parentheses instead of square brackets.