使用Pandas从主数据库创建子数据帧

时间:2022-05-02 03:38:25

I wanna create sub dataframes from a main one My main dataframe will look more or less like this one enter image description here I wanna be able to have as a sub-dataframe like the following :

我想从一个主数据框创建子数据帧我的主数据框看起来或多或少像这个输入图像描述在这里我想能够像下面这样的子数据帧:

first sub dataframe second sub dataframe

第一个子数据帧第二个子数据帧

and all the rest for example in an another frame. My goal is to transform correctly my big dataframe into sub dataframe.

而所有其余的例如在另一个框架中。我的目标是将我的大数据帧正确转换为子数据帧。

Any help will be appreciated, thanks :-)

任何帮助将不胜感激,谢谢:-)

1 个解决方案

#1


0  

You can take a rectangular section with numeric indices like this:

您可以采用带有数字索引的矩形部分,如下所示:

df.iloc[4:8, 0:8] # four rows, eight columns

Or you can use loc with column and row labels (but your data seem to be numerically labeled).

或者您可以使用带有列和行标签的loc(但您的数据似乎是用数字标记的)。

#1


0  

You can take a rectangular section with numeric indices like this:

您可以采用带有数字索引的矩形部分,如下所示:

df.iloc[4:8, 0:8] # four rows, eight columns

Or you can use loc with column and row labels (but your data seem to be numerically labeled).

或者您可以使用带有列和行标签的loc(但您的数据似乎是用数字标记的)。