Skip to content
Advertisement

bypandas shape (n,1) to shape (n,)

I have a pandas dataframe and I want to convert it from (n,1) to shape (n,). Probably I have to use squeeze but can’t figure out, How to. squeeze documentation

I also tried z['0']=z['0'].squeeze() but it didn’t help.
How can I convert?

Advertisement

Answer

z=z.squeeze() works the best and keeps the result dataframe. of course maybe its because I just had one columns, and didn’t check it for more columns.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement