Nou*_*ra 6 python data-cleaning
我想删除主题标签符号 ( '#') 和分隔单词 ( '_') 的下划线
例子: "this tweet is example #key1_key2_key3"
我想要的结果: "this tweet is example key1 key2 key3"
我的代码使用字符串:
#Remove punctuation , # Hashtag Symbol
translate_table = dict((ord(char), None) for char in string.punctuation)
cleaned_combined_tweets.translate(translate_table)
Run Code Online (Sandbox Code Playgroud)
这给出了结果: "this tweet is example key1key2key3"
>>> "this tweet is example #key1_key2_key3".replace("#", "").replace("_", " ")
Run Code Online (Sandbox Code Playgroud)