I have some data I am working with, and when I input
train.Id is a pandas Series and is one dimensional.
train is a pandas DataFrame and is two dimensional.
shape is an attribute that both DataFrames and Series have. It is always a tuple. For a Series the tuple has only only value
(x,). For a DataFrame shape is a tuple with two values
(x, y). So
train.Id.shape would also return
train.Id.shape would produce an error while
train.shape would give you the number of columns in
Furthermore, pandas Panel objects are three dimensional and
shape for it returns a tuple
(x, y, z)
train = pd.DataFrame(dict(Id=np.arange(1437), A=np.arange(1437))) print(train.shape) print(train.Id.shape) (1437, 2) (1437,)