我有一个类似这样的数据集:
category UK US Germany
sales 100000 48000 36000
budget 50000 20000 14000
n_employees 300 123 134
diversified 1 0 1
sustainability_score 22.8 38.9 34.5
e_commerce 37000 7000 11000
budget 25000 10000 10000
n_employees 18 22 7
traffic 150 mil 38 mil 12500
subsidy 33000 26000 23000
budget 14000 6000 6000
own_marketing 0 0 1
在数据集中,销售变量对应于总部的销售额。
e_commerce
是电子商务销售额,e_commerce
后面的 budget
其实是公司电子商务部门的预算。同样,subsidy
变量对应于补贴的销售额,subsidy
后面的 budget
变量是该补贴的预算。我想将数据集转换为以下格式(以英国为例):UK_main_sales UK_main_budget ... UK_e_commerce_sales UK_e_commerce_budget ...
100000 500000 37000 250000
等等。我试图通过跟踪预算变量来对不同部门的变量进行分类,因为它总是紧随部门之后,但我没有成功。
英国的完整变量列表应该像这样:
UK_main_sales
UK_main_budget
UK_main_n_employees
UK_main_diversified
UK_main_sustainability_score
UK_e_commerce (we could also add sales but I think it is simpler without sales)
UK_e_commerce_budget
UK_e_commerce_n_employees
UK_e_commerce_traffic
UK_subsidy
UK_subsidy_budget
UK_subsidy_own_marketing
有什么想法吗?