运行循环时更新另一个数据框

问题描述

我编写了以下for循环,希望在每次迭代期间更新主数据框(仅一行)的“问题”列。但是,未进行任何更新,并且该值仍为认值。有人可以帮我吗?非常感谢。

我的数据框如下:

enter image description here

for i in range(1):
    if Tweets_df['main tweet (*** means no)'].iloc[i] == "***": # Assume this is true
        if len(Tweets_df['reply_to'].iloc[i]) != 1: # Assume this is true

            # Assume Trans is a dataframe and already existing
            New = pd.merge(Tweets_df,Trans,on='conversation_id',how='inner') # Find the corresponding conversation id
            Tweets_df.iloc[i]['question'] = New.iloc[-1]['tweet_y']

完成循环后,Tweets_df.iloc [0] ['question']保持为0。有人看到我错了吗?再次感谢您。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)