如何改变 pandas 数据帧的形状(具有“L”的行号)? [英] How to change the shape of a Pandas Dataframe (row number with an "L")?

查看:125
本文介绍了如何改变 pandas 数据帧的形状(具有“L”的行号)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一列形状为(362L,)的一列熊猫数据框,并希望将其更改为(362,103)。如何做到这一点?

I have a one column pandas dataframe of the shape (362L,), and would like to change it to (362, 103). How can I do that?

推荐答案

只是想想,由于形状的对象(362L, )真的是一个大熊猫系列,我只需要将其更改为数据框,如下所示:

Just figured out, since the object of the shape (362L,) is really a pandas series, I just need to change it to dataframe, like this:

pd.DataFrame(df)

就是这样!

这篇关于如何改变 pandas 数据帧的形状(具有“L”的行号)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆