熊猫与2个数据片段合并

时间:2020-11-12 16:00:08

标签: python pandas

我有以下内容:

path_BestEffort="BestEffort.txt"
path_Demands="ConnectionServiceDemand.txt"

data_demands = pd.read_csv(path_Demands,sep='\t',header=None)
data_BestEfforts = pd.read_csv(path_BestEffort,sep='\t',header=None)

data_demands在哪里

0     #ConnectionID  ServiceDemandComponent  ServiceDemandComponentValue   
1        CN01207493                 LoadFWD                    1400000.0   
2        CN01207494                 LoadFWD                    2450000.0   
3        CN01207495                 LoadFWD                    1.010e+07   
4        CN01207496                 LoadFWD                    1750000.0   
...             ...                     ...                          ...   
3358     CN01210498                 LoadFWD                    2800000.0   
3359     CN01210499                 LoadFWD                    1400000.0   
3360     CN01210500                 LoadFWD                    2100000.0   
3361     CN01210501                 LoadFWD                     350000.0   
3362     CN01210502                 LoadFWD                    1050000.0   
    [3363 rows x 5 columns]  

data_BestEffort在哪里

              0
0    CN01207495
1    CN01207501
2    CN01207504
3    CN01207505
4    CN01207510
..          ...
699  CN01210489
700  CN01210492
701  CN01210496

[702行x 1列]

我想用data_BestEffort进行data_demands的内部联接,并仅使用与`data_BestEffort对应并找到的#ConnectionID打印data_demands。如下所示:

0     #ConnectionID  ServiceDemandComponent  ServiceDemandComponentValue   
1        CN01207495                 LoadFWD                    2400000.0   
2        CN01207501                 LoadFWD                    200000.0   
3        CN01207504                 LoadFWD                    3.010e+07   
4        CN01207505                 LoadFWD                    1250000.0   
...             ...                     ...                          ...   
699     CN01210489                 LoadFWD                    0.0   
700     CN01210492                 LoadFWD                    2800000.0   
701     CN01210496                 LoadFWD                    1000000.0  

0 个答案:

没有答案