BUG: Output all columns even if subsetting columns after groupby #37737
Labels
Apply
Apply, Aggregate, Transform, Map
Bug
Groupby
Nested Data
Data where the values are collections (lists, sets, dicts, objects, etc.).
Uh oh!
There was an error while loading. Please reload this page.
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Problem
I would like create a dictionary from pandas dataframe using groupby, which the key is the group which is used in pandas groupby and the value is list of the groupby output.
When subsetting a single column after groupby, it works well,
but when subsetting multiple columns, it outputs the list of dataframe.columns.
I checked raw output when subsetting columns after groupby and found that it outputs all columns even if subsetting columns after groupby.
Expected Output
For 1st example:
And for 2nd example:
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2a7d332
python : 3.8.5.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-29-generic
Version : #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : None
LOCALE : en_US.UTF-8
pandas : 1.1.2
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 47.1.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : 4.9.3
bottleneck : None
fsspec : 0.8.4
fastparquet : 0.4.1
gcsfs : None
matplotlib : 3.3.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.16.0
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.3
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : 0.51.2
The text was updated successfully, but these errors were encountered: