我有一个数据框(df_full)像这样:
|cust_id|address |store_id|email |sales_channel|category|
-------------------------------------------------------------------
|1234567|123 Main St|10SjtT |[email protected]|ecom |direct |
|4567345|345 Main St|10SjtT |[email protected]|instore |direct |
|1569457|876 Main St|51FstT |[email protected]|ecom |direct |
并且我想将最后4个字段组合成一个像这样的字典的元数据字段:
|cust_id|address |metadata |
-------------------------------------------------------------------------------------------------------------------
|1234567|123 Main St|{'store_id':'10SjtT', 'email':'[email protected]','sales_channel':'ecom', 'category':'direct'} |
|4567345|345 Main St|{'store_id':'10SjtT', 'email':'[email protected]','sales_channel':'instore', 'category':'direct'}|
|1569457|876 Main St|{'store_id':'51FstT', 'email':'[email protected]','sales_channel':'ecom', 'category':'direct'} |
那可能吗?我已经看到了一些关于堆栈溢出的解决方案,但是它们都无法解决将两个以上字段组合成字典字段的问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句