【问题标题】:How can I remove the non-alphanumeric (English) characters in a series containing strings while retaining spaces?如何在保留空格的同时删除包含字符串的系列中的非字母数字(英文)字符?
【发布时间】:2019-03-05 23:59:08
【问题描述】:

目前,我有:

[re.sub(r'\W', '', i) for i in training_data.loc[:, 'Text']]

但是,印地语字符仍然存在,并且所有空格都被删除。有什么想法吗?

【问题讨论】:

    标签: python pandas nlp


    【解决方案1】:

    否定可能会有所帮助

    import re
    import string    
    
    re.sub(f'[^{string.printable}]', '', 'asdf #$שדגכ')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-21
      • 1970-01-01
      • 2021-09-22
      • 1970-01-01
      • 2014-01-07
      • 1970-01-01
      • 2020-10-20
      相关资源
      最近更新 更多