小编S.B*_*B.G的帖子

当条件为真时,Pandas将数据帧分成多个

我有一个数据框,如下面的df.我想为条件为真的每个数据块创建一个新的数据帧,这样它就会返回df_1,df_2 .... df_n.

|      df           |       |  df_1 |   | df_2  |
| Value | Condition |       | Value |   | Value |
|-------|-----------|       |-------|---|-------|
| 2     | True      |   |   | 2     |   | 0     |
| 5     | True      |   |   | 5     |   | 5     |
| 4     | True      |   |   | 4     |   |       |
| 4     | False     |   |   |       |   |       |
| 2     | False     |   |   |       |   |       | …
Run Code Online (Sandbox Code Playgroud)

python split python-3.x pandas

5
推荐指数
2
解决办法
2957
查看次数

标签 统计

pandas ×1

python ×1

python-3.x ×1

split ×1