I have pandas dataframe whose shape is (4628,).
How do I change the shape of dataframe to (4628,1)?
>Solution :
You might have a Series, you can turn it into DataFrame with Series.to_frame
s = pd.Series(range(10))
out = s.to_frame('col_name') # or .to_frame()
print(s.shape)
(10,)
print(out.shape)
(10, 1)
Don’t know how you get that Series, if you use a label like df['a'], you can try passing a list of labels instead, like df[['a']]