select 列中包含字符串的两个单元格之间的所有单元格 python pandas
select all cells between two cells that contain string in a column python pandas
美好的一天!我有一个包含 3 列的数据框 df1:"One"、"Two" 和 "Three"。列 'one' 看起来像:
df
我想提取 'B' 和 'H' 之间的所有内容,然后将所有内容粘贴到单元格 (1,'Two') 或列 'B' 旁边 'Two'.
所以你想要这样的东西:
df['Two'].iloc[1] = df['One'][df['One'].between('B', 'H', inclusive=False)].tolist()
索引 1
列 Two
处的值将是:
[B, C, D, E, F, G, H]
美好的一天!我有一个包含 3 列的数据框 df1:"One"、"Two" 和 "Three"。列 'one' 看起来像:
df
我想提取 'B' 和 'H' 之间的所有内容,然后将所有内容粘贴到单元格 (1,'Two') 或列 'B' 旁边 'Two'.
所以你想要这样的东西:
df['Two'].iloc[1] = df['One'][df['One'].between('B', 'H', inclusive=False)].tolist()
索引 1
列 Two
处的值将是:
[B, C, D, E, F, G, H]