我有一个熊猫面板A,我想向A添加另一个面板B。 我的问题:将面板B添加到A后,值是NaN。 为什么会这样?
以下示例显示了问题:
import pandas as pd
Panel3D=pd.Panel() #create an empty panel
print(Panel3D)
#OUTPUT:
#<class 'pandas.core.panel.Panel'>
#Dimensions: 0 (items) x 0 (major_axis) x 0 (minor_axis)
#Items axis: None
#Major_axis axis: None
#Minor_axis axis: None
#creating some arrays:
array1=np.array([[1,2,3],[4,5,6],[7,8,9]])
array2=np.array([[11,22,33],[44,55,66],[77,88,99]])
array3=np.array([[101,102,103],[101,102,103],[101,102,103]])
#creating pandas dataframes
dataset1={1000: pd.DataFrame(array1), 2000: pd.DataFrame(array2)}
dataset2={3000: pd.DataFrame(array3)}
#creating a panel with some values
subPanel = pd.Panel(dataset1)
subPanel.values
#OUTPUT:
#array([[[ 1, 2, 3],
# [ 4, 5, 6],
# [ 7, 8, 9]],
# [[11, 22, 33],
# [44, 55, 66],
# [77, 88, 99]]])
#add 'subpanel' to 'Panel3d
Panel3D=Panel3D.add(subPanel)
Panel3D.values
#OUTPUT:
#array([[[nan, nan, nan],
# [nan, nan, nan],
# [nan, nan, nan]],
# [[nan, nan, nan],
# [nan, nan, nan],
# [nan, nan, nan]]])
创建“子面板”效果很好。但是在“ Panel3D = Panel3D.add(subPanel)”之后,这些值会丢失。 我该如何解决该问题? 谢谢!