Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[ ] I have confirmed this bug exists on the latest version of pandas.
-
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
d = {'UserId': {0: '092202ce-ac51-433b-9827-2c1264b6783f@tunnel.msging.net',
1: '092202ce-ac51-433b-9827-2c1264b6783f@tunnel.msging.net',
2: '092202ce-ac51-433b-9827-2c1264b6783f@tunnel.msging.net',
3: '092202ce-ac51-433b-9827-2c1264b6783f@tunnel.msging.net',
4: '092202ce-ac51-433b-9827-2c1264b6783f@tunnel.msging.net',
5: '092202ce-ac51-433b-9827-2c1264b6783f@tunnel.msging.net',
6: '092202ce-ac51-433b-9827-2c1264b6783f@tunnel.msging.net',
7: '092202ce-ac51-433b-9827-2c1264b6783f@tunnel.msging.net',
8: '092202ce-ac51-433b-9827-2c1264b6783f@tunnel.msging.net',
9: '092202ce-ac51-433b-9827-2c1264b6783f@tunnel.msging.net'},
'BotId': {0: 'claroresidentialsales@msging.net',
1: 'claroresidentialsales@msging.net',
2: 'claroresidentialsales@msging.net',
3: 'claroresidentialsales@msging.net',
4: 'claroresidentialsales@msging.net',
5: 'claroresidentialsales@msging.net',
6: 'claroresidentialsales@msging.net',
7: 'claroresidentialsales@msging.net',
8: 'claroresidentialsales@msging.net',
9: 'claroresidentialsales@msging.net'}}
df = pd.DataFrame(d,dtype='category')
print(df.groupby('BotId',observed=True)['UserId'].unique().values.shape)
Issue Description
If you take a closer look at the given result you will notice the given array result, comes with a shape of one dimension with only one value, when in reality the expected result is to be an array of shape 10.
Expected Behavior
The shape of the ndarray should be 10.
Installed Versions
INSTALLED VERSIONS
------------------
commit : 91111fd99898d9dcaa6bf6bedb662db4108da6e6
python : 3.9.15.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19044
machine : AMD64
processor : AMD64 Family 25 Model 80 Stepping 0, AuthenticAMD
byteorder : little
LC_ALL : None
LANG : None
LOCALE : pt_BR.cp1252
pandas : 1.5.1
numpy : 1.23.4
pytz : 2022.1
dateutil : 2.8.2
setuptools : 65.5.0
pip : 22.2.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.6.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : 1.3.5
brotli :
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.5.3
numba : None
numexpr : 2.8.4
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : 8.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.9.3
snappy : None
sqlalchemy : None
tables : None
tabulate : 0.9.0
xarray : 2022.12.0
xlrd : None
xlwt : None
zstandard : None
tzdata : None
Comment From: Sirmadeira
Just noticed that in the given sample, the groupby only afflicts a single value