我有一列包含文本(多个单词),然后是一个数字(数字量)。它们由空格分隔。如何将它们分成两列?
1. Special Education Benefit 1,400.00
2. Accidental Death 123,000.00
3. Blanket Medical Indemnity - Accident 350
4. Blanket Medical Indemnity - Accident 250
5. Blanket Medical Indemnity - Accident 150
6. Accidental Death 65,000.00
7. Special Education Benefit 1,000.00
所需输出:
Column1 Column2
1. Special Education Benefit 1,400.00
2. Accidental Death 123,000.00
3. Blanket Medical Indemnity - Accident 350
4. Blanket Medical Indemnity - Accident 250
5. Blanket Medical Indemnity - Accident 150
6. Accidental Death 65,000.00
7. Special Education Benefit 1,000.00
所以: 不同栏目中的“特殊教育”和“1400.00”, “意外死亡”和“123,000.00”在不同的列
最佳答案
我们做rsplit
df.col.str.rsplit(' ', n=1,expand=True)
关于python - 将数据帧字符串列分为两列 : one with multiple text words, 和一个数字量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62347318/