我在处理表的过程中使用了panda,并且我希望使用具有条件的列CardCode
添加2列。我有一个包含3列CardCode / Id_customer / Id_group
的用户表,我想根据(customer_id and group_id)
在我的第一个数组CardCode
中添加2列。
这是我的第一张桌子(csv文件)
CardCode ItemCode ItemCodeP Amount Price Currency Discount ListNum
FromDate ToDate Type ReducType KeyItem
0 C8500165 BTHC48 BTHC48 1 65,000000 EUR ,000000 2 2018-10-18 00:00:00 2050-12-31 00:00:00 SPP2 amount BTHC48_C8500165_SPP2
1 C8500165 BTHC48 BTHC48 5 59,000000 EUR ,000000 2 2018-10-18 00:00:00 2050-12-31 00:00:00 SPP2 amount BTHC48_C8500165_SPP2
2 C8500165 BTHC48 BTHC48 10 49,000000 EUR ,000000 2 2018-10-18 00:00:00 2050-12-31 00:00:00 SPP2 amount BTHC48_C8500165_SPP2
3 C1400164 BTHC48 BTHC48 1 65,000000 EUR ,000000 2 2018-10-18 00:00:00 2050-12-31 00:00:00 SPP2 amount BTHC48_C1400164_SPP2
4 C1400164 BTHC48 BTHC48 5 59,000000 EUR ,000000 2 2018-10-18 00:00:00 2050-12-31 00:00:00 SPP2 amount BTHC48_C1400164_SPP2
... ... ... ... ... ... ... ... ... ... ... ... ... ...
99994 C9204154 369398 369398 1 445,980000 EUR 30,000000 2 1980-01-01 00:00:00 2050-12-31 00:00:00 OEDG-52 percentage 369398_C9204154_OEDG-52
99995 C7300423 69031190 69031190 1 77,220000 EUR 20,000000 2 1980-01-01 00:00:00 2050-12-31 00:00:00 OEDG-52 percentage 69031190_C7300423_OEDG-52
99996 C3800239 50001160 50001160 1 -1,000000 EUR 40,000000 0 1980-01-01 00:00:00 2050-12-31 00:00:00 OEDG-52 percentage 50001160_C3800239_OEDG-52
99997 C0200028 000008309 000008309_I0450 1 779,440000 EUR 20,000000 2 1980-01-01 00:00:00 2050-12-31 00:00:00 OEDG-52 percentage 000008309_I0450_C0200028_OEDG-52
99998 C0700024 000008309 000008309_I1000 1 779,440000 EUR 40,000000 2 1980-01-01 00:00:00 2050-12-31 00:00:00 OEDG-52 percentage 000008309_I1000_C0700024_OEDG-52
我的阵列客户:
0 1 2
0 C6710024 1 10
1 C0100003 7 10
2 C0100008 8 10
3 C0100048 9 10
4 C0100078 11 10
... ... ... ..
1899 C4400373 2798 10
1900 C7800620 2801 10
1901 C6303124 2802 10
1902 C4600023 2808 10
1903 C0600345 2811 10
警告第一板上有几个相同的CardCode。
谢谢您的帮助。
答案 0 :(得分:0)
如果我的问题正确,您是否要基于csv文件中“ CardCod”的值向“我的阵列客户”添加两个新列(“ customer_id”和“ group_id”)?