对大熊猫来说非常陌生,所以任何解释和解决办法都是值得赞赏的。在
我有一个数据帧,比如
Company Zip State City
1 *CBRE San Diego, CA 92101
4 1908 Brands Boulder, CO 80301
7 1st Infantry Division Headquarters Fort Riley, KS
10 21st Century Healthcare, Inc. Tempe 85282
15 AAA Jefferson City, MO 65101-9564
我想将数据中的Zip State city列拆分为3个不同的列。使用这篇文章的答案Pandas DataFrame, how do i split a column into two如果我没有第一篇专栏文章,我可以完成这项任务。编写一个regex来捕获所有公司只会让我捕获数据中的所有内容。在
我也试过了
^{pr2}$但这导致我失去了company列,并将多个单词的城市名称拆分为单独的列。在
如何在保留公司列数据的同时拆分上一列?在
您可以使用extract()方法:
从docs:
^{pr2}$相关问题 更多 >
编程相关推荐