It seems that the count
method no longer works on PanelGroupBy
objects, instead raising NotImplementedError
?
dr = pd.date_range("20160505", "20160507 23:00", freq="H")
test_panel = pd.Panel(data=np.random.random((2,72,2)), major_axis=dr)
gb = test_panel.groupby(pd.TimeGrouper('D', axis=1))
# works under all versions
gb.agg(pd.Panel.count)
# raises NotImplementedError under 0.17.1 and 0.18.1
# pandas 0.16.2 gives same result as previous line
gb.count()
output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 62 Stepping 4, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
pandas: 0.18.1
nose: 1.3.7
pip: 8.1.1
setuptools: 20.7.0
Cython: 0.24
numpy: 1.10.4
scipy: 0.17.0
statsmodels: 0.6.1
xarray: 0.7.2
IPython: 4.2.0
sphinx: 1.4.1
patsy: 0.4.1
dateutil: 2.5.2
pytz: 2016.3
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.5.2
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.8.5
lxml: 3.6.0
bs4: 4.4.1
html5lib: None
httplib2: 0.9.2
apiclient: 1.4.2
sqlalchemy: 1.0.12
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.39.0
pandas_datareader: 0.2.1
Comment From: jreback
its pretty easy to add, though not much effort is going to maintenance of Panel things. This is getting deprecated in 0.19.0. You can submit a PR to add it if you'd like.
Comment From: Liam3851
Ahh I see. I'm not too familiar with the code, particularly the Cython. It looks like I would just need to write a 3-d version of lib.count_level_2d and follow the pattern of DataFrameGroupBy.count? Or, given the coming deprecation of all of Panel, should I just define PanelGroupBy.count to delegate via .agg to Panel.count, fixing the regression in the least-intrusive manner?
Comment From: jreback
you wouldn't need to write any routine to actually do this. I think the path to call it is just not taken for some reason (and hits the NotImplementedError
)), e.g.
In [15]: p = tm.makePanel()
In [16]: g = p.groupby({'ItemA': 0, 'ItemB': 0, 'ItemC': 1}, axis='items').count()
NotImplementedError:
Comment From: jreback
closing as Panels are deprecated