小编M. *_* P.的帖子

How to add dataframe column data to a range of indexes in another dataframe?

I have a dataframe called df1:

        Long_ID     IndexBegin         IndexEnd
0       10000001        0                  3
1       10000002        3                  6
2       10000003        6                 10            
Run Code Online (Sandbox Code Playgroud)

I have a second dataframe called df2, which can be up to 1 million rows long:

      Short_ID
0        1
1        2
2        3
3        10
4        20
5        30
6        100
7        101
8        102
9        103
Run Code Online (Sandbox Code Playgroud)

I want to link Long_ID to Short_ID in such a way that if (IndexBegin:IndexEnd) is (0:3), …

python dataframe pandas

2
推荐指数
1
解决办法
73
查看次数

标签 统计

dataframe ×1

pandas ×1

python ×1