Found the answer myself, I was using the latest Pandas v1.2.0, where the panel has been removed from Pandas module 0.25.0 onwards.

print(pd.__version__)
print(np.__version__)
1.2.0
1.19.4

From 0.25.0 / 1.2.0 release notes

Warning: The panel has been fully removed. For N-D labeled data structures, please use xarray

unless you want to use xarray, you need to uninstall and install the version prior to that.

Answer from Jijo John on Stack Overflow
🌐
GitHub
github.com › pydata › xarray › issues › 5430
pandas support when calling xarray.open_rasterio · Issue #5430 · pydata/xarray
June 2, 2021 - When calling xarray.open_rasterio: import xarray as xr xds = xr.open_rasterio("https://github.com/mapbox/rasterio/raw/1.2.1/tests/data/RGB.byte.tif") the following error occurs: AttributeError: module 'pandas' has no attribute 'Panel' I ...
Author   jmigueldelgado
🌐
Data Science Learner
datasciencelearner.com › attributeerror-module-pandas-has-no-attribute-panel-solved
AttributeError: module 'pandas' has no attribute 'panel' ( Solved )
September 12, 2023 - After downgrading the module if you run the same code you will not get the module ‘pandas’ has no attribute ‘panel’ error. The other solution for this error is that you should use the other function according to the current version of the pandas’ module. The same task can be achieved by using the to_xarray() function.
🌐
GitHub
github.com › quantling › pyndl › issues › 210
module `pandas` has no attribute `Panel` · Issue #210 · quantling/pyndl
June 7, 2022 - from pyndl.ndl import ndl File "/rds/homes/m/milinp/.local/lib/python3.7/site-packages/pyndl/ndl.py", line 24, in import xarray as xr File "/rds/homes/m/milinp/miniconda3/envs/petar/lib/python3.7/site-packages/xarray/init.py", line 11, in from .core.combine import combine_by_coords, combine_nested, auto_combine File "/rds/homes/m/milinp/miniconda3/envs/petar/lib/python3.7/site-packages/xarray/core/combine.py", line 8, in from .dataarray import DataArray File "/rds/homes/m/milinp/miniconda3/envs/petar/lib/python3.7/site-packages/xarray/core/dataarray.py", line 12, in from . import ( File "/rds/
Author   striatum
🌐
Xarray
docs.xarray.dev › en › v2025.01.0 › user-guide › pandas.html
Working with pandas
To allow pandas developers to focus more on its core functionality built around the DataFrame, pandas removed Panel in favor of directing users who use multi-dimensional arrays to xarray.
🌐
GitHub
github.com › tensorflow › tensorflow › issues › 26266
AttributeError: module 'pandas' has no attribute 'compat' · Issue #26266 · tensorflow/tensorflow
March 1, 2019 - Hi, I am trying to use ScipyOptimizerInterface() in the tensorflow, but it gave the following attribute error AttributeError: module 'pandas' has no attribute 'compat'. By going thr...
Author   g7dhaliwal
🌐
CopyProgramming
copyprogramming.com › howto › module-pandas-has-no-attribute-corr
Python: Missing Attribute 'corr' in 'pandas' Module
January 30, 2021 - 11 panaldata[ticker] = panaldata[ticker][["Open","High","Low","Close","Volume"]] 12 #print(panaldata[ticker].head()) ---> 13 panelda = pd.Panel() 14 #panelda.minor_axis = ["Open","High","Low","Close","Volume"] 15 #panelda.major_axis = panel.major_axis.tz_localize(pytz.ist) c:\miniconda\lib\site-packages\pandas\__init__.py in __getattr__(name) 242 return _SparseArray 243 --> 244 raise AttributeError(f"module 'pandas' has no attribute '{name}'") 245 246 AttributeError: module 'pandas' has no attribute 'Panel' ... I discovered the solution on my own. It turns out that I had been utilizing the most recent version of Pandas (v1.2.0), which no longer includes the panel feature that was present in earlier versions starting from 0.25.0. print(pd.__version__) print(np.__version__) 1.2.0 1.19.4 ... Warning: The panel has been fully removed. For N-D labeled data structures, please use xarray
🌐
Stack Overflow
stackoverflow.com › questions › 72581248 › how-to-solve-the-error-module-pandas-has-no-attribute-panel
python - How to solve the error module 'pandas' has no attribute 'Panel'? - Stack Overflow
If you want to use the code as it is, you'll have to install a pandas version < 0.25 (e.g. pip install pandas==0.24.2). But since the error is coming from statsmodels you are most likely running an outdated version.
Find elsewhere
🌐
GitHub
github.com › brainiak › brainiak › issues › 515
GBRSA import error: Module 'pandas' has no attribute 'Panel' · Issue #515 · brainiak/brainiak
June 13, 2022 - I am attempting to follow the tutorial for GBRSA here: https://github.com/brainiak/brainiak/blob/master/examples/reprsimil/bayesian_rsa_example.ipynb but I receive an error that the module 'pandas' has no attribute 'Panel.' I've followed...
Author   salilabwfu
🌐
Pandas
pandas.pydata.org › pandas-docs › version › 0.23 › generated › pandas.Panel.html
pandas.Panel — pandas 0.23.1 documentation
Enter search terms or a module, class or function name · Deprecated since version 0.20.0: The recommended way to represent 3-D data are with a MultiIndex on a DataFrame via the to_frame() method or with the xarray package. Pandas provides a to_xarray() method to automate this conversion
🌐
GitHub
github.com › bexer › pyeviews › issues › 7
AttributeError: module 'pandas.core' has no attribute 'panel' · Issue #7 · bexer/pyeviews
August 31, 2021 - If you try to use a numpy array, list, dict as data in PutPythonAsWF(data, app=eviewsapp, newwf=False), we get an error in this elif statement: elif isinstance(obj, pa.core.panel.Panel): · Remove line 211 to 224 in init.py fixes those error and ...
Author   azacha
🌐
GitHub
github.com › pandas-dev › pandas › issues › 19155
AttributeError: module 'pandas' has no attribute 'Data' · Issue #19155 · pandas-dev/pandas
import pandas as pd dict={ "country":["Brasil", "Russia", "India", "China", "South Africa"], "capital":["Brasilia", "Moscow", "New Delhi", "Beijing", "Pretoria"], "area":[8.51, 17.10, 3.28, 9.59, 1.22], "population":[200.4, 143.5, 1252,1357,52.98] } ... AttributeError Traceback (most recent call last) in () ----> 1 brics = pd.Data.Frame(dict) #no success but works fine in the terminal · AttributeError: module 'pandas' has no attribute 'Data'
🌐
Xarray
docs.xarray.dev › en › v0.12.3 › pandas.html
Working with pandas — xarray 0.12.3 documentation
April 25, 2023 - Panel, pandas’ data structure for 3D arrays, has always been a second class data structure compared to the Series and DataFrame. To allow pandas developers to focus more on its core functionality built around the DataFrame, panads has deprecated Panel.
🌐
Scaler
scaler.com › home › topics › pandas › panel in pandas
Pandas Dataframe - Scaler Topics
December 15, 2022 - If we run the panel program on the pandas latest version, then it will throw an error like AttributeError: module 'pandas' has no attribute 'Panel' So, it's necessary to install the pandas version below 0.25 before running any Panel program.
🌐
Pandas
pandas.pydata.org › pandas-docs › version › 0.23.4 › generated › pandas.Panel.html
pandas.Panel — pandas 0.23.4 documentation
Enter search terms or a module, class or function name · Deprecated since version 0.20.0: The recommended way to represent 3-D data are with a MultiIndex on a DataFrame via the to_frame() method or with the xarray package. Pandas provides a to_xarray() method to automate this conversion
🌐
Xarray
docs.xarray.dev › en › v0.9.0 › pandas.html
Working with pandas — xarray 0.9.0 documentation
To allow pandas developers to focus more on its core functionality built around the DataFrame, pandas plans to eventually deprecate Panel. xarray has most of Panel‘s features, a more explicit API (particularly around indexing), and the ability to scale to >3 dimensions with the same interface.
Top answer
1 of 2
1

xarray assignments are not as elegant as the pandas panel. Lets say we want to add a fourth item in the data array above. Here is how it works:

four=xr.DataArray(np.ones((1,4,5)), coords=[['four'],pd.date_range('1/1/2000', periods=4),['a', 'b', 'c', 'd','e']], 
                  dims=['items','major_axis','minor_axis'])

pxc=xr.concat([px,four],dim='items')

Whether the operation is on items or major/minor axis, a similar logic prevails. For deleting use

pxc.drop(['four'], dim='items')
2 of 2
1

xarray.DataArray is based on a single NumPy array internally, so it cannot be efficiently resized or appended to. Your best option is to make a new, larger DataArray with xarray.concat.

The data structure you're probably looking if you want to add items to a pd.Panel is xarray.Dataset. These are easiest to construct from the multi-indexed DataFrame equivalent to a Panel:

# First, make a DataFrame with a MultiIndex
>>> df = panel.to_frame()

>>> df.head()
                       one       two     three
major      minor
2000-01-01 a      0.278958  0.676034 -1.544726
           b     -0.918150 -2.707339 -0.552987
           c      0.023479  0.175528 -0.817556
           d      1.798001 -0.142016  1.390834
           e      0.256575  0.265369 -1.829766

# Now, convert the DataFrame with a MultiIndex to xarray
>>> ds = df.to_xarray()

>>> ds
<xarray.Dataset>
Dimensions:  (major: 4, minor: 5)
Coordinates:
  * major    (major) datetime64[ns] 2000-01-01 2000-01-02 2000-01-03 2000-01-04
  * minor    (minor) object 'a' 'b' 'c' 'd' 'e'
Data variables:
    one      (major, minor) float64 0.279 -0.9182 0.02348 1.798 0.2566 2.41 ...
    two      (major, minor) float64 0.676 -2.707 0.1755 -0.142 0.2654 ...
    three    (major, minor) float64 -1.545 -0.553 -0.8176 1.391 -1.83 ...

# You can assign a DataFrame if it has the right column/index names
>>> ds['four'] = pd.DataFrame(np.ones((4,5)),
...                           index=pd.date_range('1/1/2000', periods=4, name='major'),
...                           columns=pd.Index(['a', 'b', 'c', 'd', 'e'], name='minor'))

# or just pass a tuple directly:
>>> ds['five'] = (('major', 'minor'), np.zeros((4, 5)))

>>> ds
<xarray.Dataset>
Dimensions:  (major: 4, minor: 5)
Coordinates:
  * major    (major) datetime64[ns] 2000-01-01 2000-01-02 2000-01-03 2000-01-04
  * minor    (minor) object 'a' 'b' 'c' 'd' 'e'
Data variables:
    one      (major, minor) float64 0.279 -0.9182 0.02348 1.798 0.2566 2.41 ...
    two      (major, minor) float64 0.676 -2.707 0.1755 -0.142 0.2654 ...
    three    (major, minor) float64 -1.545 -0.553 -0.8176 1.391 -1.83 ...
    four     (major, minor) float64 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 ...
    five     (major, minor) float64 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ...

For more on transitioning from pandas.Panel to xarray, read this section in the xarray docs: http://xarray.pydata.org/en/stable/pandas.html#transitioning-from-pandas-panel-to-xarray