import pandas as pd df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}) result = type(df['A']) print(result)
When you select one column from a DataFrame using df['A'], it returns a Series object representing that column.
import pandas as pd s = pd.Series([10, 20, 30]) df = pd.DataFrame({'X': [10, 20, 30]}) print(s.shape, df.shape)
A Series has a shape with one dimension (number of elements), while a DataFrame has two dimensions (rows, columns).
import pandas as pd s1 = pd.Series([1, 2, 3], name='A') s2 = pd.Series([4, 5, 6], name='B') df = pd.concat([s1, s2], axis=1) print(df)
Using pd.concat with axis=1 stacks Series side by side as columns, forming a DataFrame.
A DataFrame is like a table made of multiple Series (columns) that share the same index (row labels).
import pandas as pd df = pd.DataFrame({'A': [1, 2, 3]}) s = pd.Series(df['A'], index=[0, 1])
The error occurs because the Series constructor expects the index length to match the data length. Here, data has length 3 but index has length 2.
