Python 熊猫:将一行字符串分成4列;问题:列由逗号、制表符和空格分隔

Python 熊猫:将一行字符串分成4列;问题:列由逗号、制表符和空格分隔,python,pandas,Python,Pandas,我有一个文本文件,我正在尝试将一行的条目分离到一个新列。一行如下所示: 12:00,Info“此处有18个空格”ABC一些文本您可以使用正则表达式模式精确定义拆分字符串行的规则: import pandas as pd df = pd.DataFrame(data={ "A": [ "12:00, Info ABC some text\tmoretext" ] }) # split on comma followe

我有一个文本文件,我正在尝试将一行的条目分离到一个新列。一行如下所示:


12:00,Info“此处有18个空格”ABC一些文本您可以使用正则表达式模式精确定义拆分字符串行的规则:

import pandas as pd

df = pd.DataFrame(data={
    "A": [
        "12:00, Info    ABC some text\tmoretext"
    ]
})

# split on comma followed by a space OR 1+ whitespace (inc. tab) character 
df.A.str.split(r", |\s+", expand=True)

       0     1    2     3     4         5
0  12:00  Info  ABC  some  text  moretext


你想要的结果到底是什么?“table.ID.str.split(expand=True)”将拆分为其元素
import pandas as pd

df = pd.DataFrame(data={
    "A": [
        "12:00, Info    ABC some text\tmoretext"
    ]
})

# split on comma followed by a space OR 1+ whitespace (inc. tab) character 
df.A.str.split(r", |\s+", expand=True)

       0     1    2     3     4         5
0  12:00  Info  ABC  some  text  moretext