📌  相关文章
📜  如何将文本列拆分为两个单独的列? - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:03.098000             🧑  作者: Mango

代码示例1
import pandas as pd 

df = pd.DataFrame(["STD, City    State",
"33, Kolkata    West Bengal",
"44, Chennai    Tamil Nadu",
"40, Hyderabad    Telengana",
"80, Bangalore    Karnataka"], columns=['row'])

out = pd.DataFrame(df.row.str.split(' ',2).tolist(),columns=['STD','City','State'])
out.drop(index=0,inplace=True)