【发布时间】:2020-09-12 02:30:57
【问题描述】:
我要做的是从列“in_reply_to_user_id”(不在图片中,因为 df 太宽而无法容纳)与给定 id 具有相同值的行中获取文本,并将文本附加到然后我想把它放在一个新列中。例如,列“in_reply_to_user_id”等于第一条推文的“id”的所有推文中的文本应该放在一个列表中,然后将其附加到数据框中称为“回复”的新列中。以下是我尝试过的一些事情:
for i in testb['in_reply_to_user_id']:
for j in test['user.id']:
if i == j:
index=testb.index()
test['replies'].append(testb['text'].iloc[index]) ```
test would be the original dataframe and testb would be a copy that i created in order to try to run the code above. it is just a copy of test.
【问题讨论】: