pandas.Panel弃用警告的实际建议是什么? [英] What is the pandas.Panel deprecation warning actually recommending?
问题描述
我有一个使用pandas Panels生成MultiIndex pandas DataFrames的程序包.但是,每当我使用pandas.Panel时,都会收到以下DeprecationError:
I have a package that uses pandas Panels to generate MultiIndex pandas DataFrames. However, whenever I use pandas.Panel, I get the following DeprecationError:
弃用警告: 面板已弃用,在以后的版本中将被删除. 推荐的表示这些类型的3维数据的方法是通过Panel.to_frame()方法在DataFrame上使用MultiIndex. 或者,您可以使用xarray包 http://xarray.pydata.org/en/stable/一个>. Pandas提供了
.to_xarray()
方法来帮助自动执行此转换.
DeprecationWarning: Panel is deprecated and will be removed in a future version. The recommended way to represent these types of 3-dimensional data are with a MultiIndex on a DataFrame, via the Panel.to_frame() method. Alternatively, you can use the xarray package http://xarray.pydata.org/en/stable/. Pandas provides a
.to_xarray()
method to help automate this conversion.
但是,我不明白这里的第一个建议实际上是为创建MultiIndex DataFrames建议的.如果要删除Panel,我将如何使用Panel.to_frame?
However, I can't understand what the first recommendation here is actually recommending in order to create MultiIndex DataFrames. If Panel is going to be removed, how am I going to be able to use Panel.to_frame?
为了澄清:我不是在问什么是弃用,也不是如何将我的面板转换为DataFrames.我要问的是,如果我在库中使用pandas.Panel然后使用pandas.Panel.to_frame从3D ndarrays创建MultiIndex DataFrames,而Panels将被弃用,那么制作那些没有使用面板API?
To clarify: I am not asking what deprecation is, or how to convert my Panels to DataFrames. What I am asking is, if I am using pandas.Panel and then pandas.Panel.to_frame in a library to create MultiIndex DataFrames from 3D ndarrays, and Panels are going to be deprecated, then what is the best option for making those DataFrames without using the Panel API?
例如,如果我正在执行以下操作,则将X作为形状为(N,J,K)的ndarray:
Eg, if I'm doing the following, with X as a ndarray with shape (N,J,K):
p = pd.Panel(X, items=item_names, major_axis=names0, minor_axis=names1)
df = p.to_frame()