文本处理python以摆脱\r\n\xa0

2024-09-30 01:30:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个熊猫数据框,它有一个名为description的长文本列。其中的数据来自jira web实例。我一直在尝试使用几种不同的方法删除文本中的标记,但似乎没有一种方法能够删除\r\n\xa0

这是我到目前为止所拥有的

        df['description'] = df['description'].replace(r'http\S+', '', regex=True).replace(r'www\S+', '', regex=True)
        df['description'] = df['description'].replace(r'[^\x00-\x7F]+', ' ', regex = True)
        df['description'] = df['description'].replace(r'\[(.+)\]\([^\)]+\)', r'\1', regex = True).replace(r'\*\*([^*]+)\*\*', r'\1',                                                                                  regex = True)
        df['description'] = df['description'].replace(r'\*([^*]+)\*',r'\1', regex = True )
        df['description'] = df['description'].astype(str).str.strip()

你知道我能在这里做什么吗?文本样本

We analyzed found the issue in Garbage Collection which crashed the JVM.\r\n\r\n\xa0\r\n\r\n\xa0\r\n\r\n_Stack: [0x00007f0b58ff1000,0x00007f0b590f1000],\xa0 sp=0x00007f0b590ef120,\xa0 free space=1016k_\r\n\r\n_Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)_\r\n\r\n_V\xa0 [libjvm.so+0x8b9e4f]\xa0 MethodData::clean_extra_data(BoolObjectClosure)+0x1cf_\r\n\r\n_V\xa0 [libjvm.so+0x63c582]\xa0 

Tags: the数据方法文本truedfsojira

热门问题