-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
Deprecate groupby() squeeze option #32380
Comments
It doesn't appear to be documented, and I'm not familiar with it. @dechamps are you interested in walking through the code to see what it's intended for? |
we should deprecate this option - i don’t think original usecases that i added are worth it |
Well the Personally I don't care much about the parameter - it's simple enough to just call |
+1 to deprecate as well; seems out of place as an argument here |
Here's an example of where it does something
Anyway, @dechamps , are you interested in submitting a pull request to deprecate it? If so, see https://pandas.pydata.org/docs/development/contributing.html - else, I'd happily take it and see the groupby logic simplified :) |
Honestly I'd be prefer you do it - I have zero familiarity with Pandas development workflows. |
Here's a rant: You deprecated squeeze in 1.1.0 in violation of your own deprecation policy introduced in 1.0.0. edit: Perhaps it was intended to throw a DeprecationWarning instead of the FutureWarning that was used. FutureWarning indicates that it has already been deprecated and user is still using it. |
we can and will deprecate things in almost every version what the policy is not to remove those depreciated until a next major version eg 2.0 we don't use DeprecationWarning because it's not shown by default and IMHO just useless FutureWarning is visible you don't have to change you code and can continue to use it if you would like |
Great to hear that it is not going away until 2.0! I'm much appreciative of the deprecation policy you provided, and I took the FutureWarning to mean something else since I expected a DeprecationWarning. Thanks for providing the rationale of FutureWarning. Arguments Against Using FutureWarning for Deprecations I think the big cause of confusion is that python changed its definition/recommendation of Deprecation and Future warnings in PEP-565, implemented in py3.7. Now instead of differentiating based on behavior, they are differentiating based on audience. "intended for other Python developers" as opposed to "intended for end users of applications that are written in Python". I think PEP565 has provided clear guidance that the type of warning that pandas should be providing for depreciations should in fact be a DeprecationWarning. With regards to visibility, as of 3.7, DeprecationWarning are only visible if called from Argument in Support of FutureWarning Final Thought |
we are unlikely to change the warning type as visibility is most important |
Hi, I need exactly this behavior when applying functions to the
|
…re. Besides, the current code is cause error when working with a newer pandas version 1.4.4. So using a work around as recommended in pandas-dev/pandas#32380
I believe it's
DataFrameGroupBy.apply() returns a DataFrame, and you use Dataframe.squeeze() on that. |
Code Sample
Problem description
I expected
.groupby(squeeze=True)
to, well, squeeze, andcount()
to return a Series. Insteadsqueeze=True
doesn't seem to do anything, andcount()
returns a DataFrame.A workaround is to write
.groupby('A').count().squeeze()
, which does work.Expected Output
Actual output
Output of
pd.show_versions()
pandas : 1.0.1
numpy : 1.17.4
pytz : 2019.3
dateutil : 2.8.1
pip : 18.1
setuptools : 44.0.0
Cython : None
pytest : 4.6.9
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.0
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.12.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.5.0
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 4.6.9
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None
The text was updated successfully, but these errors were encountered: