【发布时间】:2018-05-06 17:02:42
【问题描述】:
我正在对笔记本中的非结构化数据进行一些分析 - 它占一列信息。我想把这个唯一的专栏拉出来,做自然语言处理,看看哪些关键词最频繁和标记化。
当我在用户评论列上应用我的词标记器时,我要分析的文本:
text = df.loc[:, "User Reviews"]
行号包含在文本“用户评论”列中。
由于一些用户评论包含与行号相同的数字,这让分析变得混乱,尤其是因为我正在应用标记化并查看词频。因此,在下面的示例中,行从 1 开始,然后 2 是下一行,然后是 3,以此类推,有 10K 用户评论。
['1', 'great', 'cat', 'waiting', 'on', 'me', 'home', 'to', 'feed', 'love', 'fancy', 'feast',
'2', 'my', '3', 'dogs', 'love', 'this', '3', 'So', 'bad', 'my', '4', 'dogs', 'threw', 'up', ...]
有没有办法做到这一点?我需要text.drop 来删除该行吗?我在这里查找了一些来源:
https://www.shanelynn.ie/using-pandas-dataframe-creating-editing-viewing-data-in-python/
https://medium.com/dunder-data/selecting-subsets-of-data-in-pandas-6fcd0170be9c
但仍在苦苦挣扎。
User Reviews
0 i think my puppy likes this. She seemed to keep...
1 Its Great! My cat waiting on me to feed her. Fa...
2 My 3 dogs love this so much. Wanted to get more...
3 All of my 4 dogs threw this up. Wouldnt ever re...
4 I think she likes it. I gave it to her yesterda...
5 Do not trust this brand, dog died 3 yrs ago aft...
6 Tried and true dog food, never has issues with ...
【问题讨论】:
-
你试过
df.loc[:, "User Reviews"].values吗?我建议这样做的原因是我不确切知道您的“标记化”正在应用什么逻辑。通过提取值,您知道您只是在访问底层数组值,仅此而已。 -
@jpp 成功了!!!!非常感谢!!!!
标签: python pandas dataframe tokenize