Reputation: 40
Why does
print(data["column"].shape)
print (1819,)
whereas
print(data[["column"]].shape)
prints (1819,1)
Upvotes: 1
Views: 1823
Reputation: 508
data["column"]
returns a Pandas Series which is always always as shape (n,) i.e. it does not have columns just a single row always.
data[["column"]]
returns a Pandas DataFrame which has shape (m, n)
If you want multiple columns in a dataframe you can use the double brackets as follows.
data[["col1", "col2"]]
Upvotes: 4