I am new to Pandas and I am trying to better understand the use of the numeric_only parameter.
As you can see in the screenshot below, the goal is to pull the median number of video shares by the author's ban status. Why do I need to specify "numeric_only = True" within the median function. Why do the results pull multiple fields of the data frame when I remove the numeric_only parameter?
I would expect that by just using median(['video_share_count']) would be enough to specify that I am interested in pulling only the specific numeric field.
"Why do the results pull multiple fields of the data frame when I remove the numeric_only parameter?"
groupby.medianonly accepts one parameter:numeric_only.By running:
You're actually still using the
numeric_onlyparameter, it's equivalent to:And since
bool(['video_share_count'])evaluates toTrue, you're essentially running:So not filtering any column.
You might just want: