我正在尝试使用NetworkX建立B2C公司及其供应商的动态网络。我的数据看起来像这样(在Pandas中)。通过公司ID进行索引:
+---------+---------------------+
| Company | Supplier |
+---------+---------------------+
| Firm A | {sup1, sup2, sup 3} |
| Firm B | {sup1, sup2} |
| Firm C | {sup1, sup3} |
+---------+---------------------+
现在,如果每个公司有多个供应商,我想在原始供应商的正下方创建n-1个新行。我想要的输出看起来像这样:
+---------+----------+
| Company | Supplier |
+---------+----------+
| Firm A | sup1 |
| Firm A | sup2 |
| Firm A | sup3 |
| Firm B | sup1 |
| Firm B | sup2 |
| Firm C | sup1 |
| Firm C | sup3 |
+---------+----------+
我也想消除大括号。