我有这样一个数据框:
|customer_key|order_id|subtotal|address |
------------------------------------------------
|12345 |O12356 |123.45 |123 Road Street|
|10986 |945764 |70.00 |634 Road Street|
|32576 |678366 |29.95 |369 Road Street|
|67896 |198266 |837.69 |785 Road Street|
我想根据包含当前列名和所需列名的以下JSON对列进行重新排序/重命名:
{
"customer_key": "cust_id",
"order_id": "transaction_id",
"address": "shipping_address",
"subtotal": "subtotal"
}
要获得结果数据帧,请执行以下操作:
|cust_id|transaction_id|shipping_address|subtotal|
--------------------------------------------------
|12345 |O12356 |123 Road Street |123.45 |
|10986 |945764 |634 Road Street |70.00 |
|32576 |678366 |369 Road Street |29.95 |
|67896 |198266 |785 Road Street |837.69 |
这是可能的吗?如果这样做更简单,那么列的顺序并不重要
对于重命名和排序,您需要在重命名后重新编制索引
或:
相关问题 更多 >
编程相关推荐