简体   繁体   English

阅读大字符串并拆分每个单词在python中花费太多时间

[英]reading large string and split each word taking too much time in python

I am reading a dataframe column having comments. 我正在阅读有评论的数据框列。 The data is taking forever to read using the code below. 使用下面的代码将永远读取数据。 Is there a way to make this faster ? 有没有办法使它更快?

for val in df.Description:
    val = str(val)
    tokens = val.split()  
    for i in range(len(tokens)):
        tokens[i] = tokens[i].lower()  
        for words in tokens:
            comment = comment + words + ''

df.Description is a column of comments (basically email text) df.Description是一列评论(主要是电子邮件文本)

Update: Assuming df.Description is your column, this might be helpful: 更新:假设df.Description是您的专栏,这可能会有所帮助:

arr_string = df.Description.astype(str).values.tolist()
for val in arr_string:
    for words in val:
            comment = ''.join([comment, words])

Take a look at this . 看看这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM