Python|熊猫面板.shape
在 Pandas 中,Panel 是一个非常重要的 3D 数据容器。 3 个轴的名称旨在为描述涉及面板数据的操作提供一些语义含义,特别是面板数据的计量经济学分析。
在 Pandas中 Panel.shape可用于获取轴尺寸的元组。
Syntax: Panel.shape
Parameters: None
Returns: Return a tuple of axis dimensions
代码#1:
Python3
# importing pandas module
import pandas as pd
import numpy as np
df1 = pd.DataFrame({'a': ['Geeks', 'For', 'geeks', 'for', 'real'],
'b': [11, 1.025, 333, 114.48, 1333]})
data = {'item1':df1, 'item2':df1}
# creating Panel
panel = pd.Panel.from_dict(data, orient ='minor')
print("panel['b'] is - \n\n", panel['b'], '\n')
print("\nSize of panel['b'] is - ", panel['b'].shape)
Python3
# importing pandas module
import pandas as pd
import numpy as np
df1 = pd.DataFrame({'a': ['Geeks', 'For', 'geeks', 'for', 'real'],
'b': [11, 1.025, 333, 114.48, 1333]})
# Create a 5 * 5 dataframe
df2 = pd.DataFrame(np.random.rand(10, 2), columns =['a', 'b'])
data = {'item1':df1, 'item2':df2}
# creating Panel
panel = pd.Panel.from_dict(data, orient ='minor')
print("panel['b'] is - \n\n", panel['b'], '\n')
print("\nShape of Panel is - ", panel['b'].shape)
Python3
# importing pandas module
import pandas as pd
import numpy as np
df1 = pd.DataFrame({'a': ['Geeks', 'For', 'geeks', 'real'],
'b': [-11, +1.025, -114.48, 1333]})
df2 = pd.DataFrame({'a': ['I', 'am', 'dataframe', 'two'],
'b': [100, 100, 100, 100]})
data = {'item1':df1, 'item2':df2}
# creating Panel
panel = pd.Panel.from_dict(data, orient ='minor')
print("panel['b'] is - \n\n", panel['b'])
print("\nShape of panel['b'] is - ", panel['b'].shape)
Python3
#To check the version of pandas library
import pandas
print(pandas.__version__)
输出:
代码#2:
Python3
# importing pandas module
import pandas as pd
import numpy as np
df1 = pd.DataFrame({'a': ['Geeks', 'For', 'geeks', 'for', 'real'],
'b': [11, 1.025, 333, 114.48, 1333]})
# Create a 5 * 5 dataframe
df2 = pd.DataFrame(np.random.rand(10, 2), columns =['a', 'b'])
data = {'item1':df1, 'item2':df2}
# creating Panel
panel = pd.Panel.from_dict(data, orient ='minor')
print("panel['b'] is - \n\n", panel['b'], '\n')
print("\nShape of Panel is - ", panel['b'].shape)
输出:
代码#3:
Python3
# importing pandas module
import pandas as pd
import numpy as np
df1 = pd.DataFrame({'a': ['Geeks', 'For', 'geeks', 'real'],
'b': [-11, +1.025, -114.48, 1333]})
df2 = pd.DataFrame({'a': ['I', 'am', 'dataframe', 'two'],
'b': [100, 100, 100, 100]})
data = {'item1':df1, 'item2':df2}
# creating Panel
panel = pd.Panel.from_dict(data, orient ='minor')
print("panel['b'] is - \n\n", panel['b'])
print("\nShape of panel['b'] is - ", panel['b'].shape)
输出:
注意:面板已从 Pandas 模块 0.25.0 开始删除。
Python3
#To check the version of pandas library
import pandas
print(pandas.__version__)