[英]how to make multiple column base on multiple category of values of a column in python
import pandas as pd df = pd.DataFrame( ['Expenses','1. Interest Expense','1.1 On Deposit Liabilities','1.1.1 Saving Account','1.1.2 Fixed Account','1.1.2.1 Up to 3 months Fixed Account','1.1.2.2 3 to 6 months Fixed Account','1.1.2.3 6 months to 1 year Fixed Account','1.1.2.4 Above 1 year Fixed Account','1.1.3 Call Deposit','1.1.4 Certificate of Deposit','1.2 On Borrowing','2. Commission Expense','3. Staff Expense','4. Office Operating Expenses','5. Foreign Exchange Loss'] , columns=['level1'])
如果您的输入在string
list
,则可以使用
[x.split()[0] for x in columns]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.