使用相同数据帧中的熊猫的Vlookup

时间:2020-07-08 18:10:58

标签: python excel pandas

python和pandas的新手,很难找到以下解决方案:

我有一个包含以下数据的电子表格;我正在尝试为每个Facebook注释及其父帖子中的相应文本创建一个新列。

所以从这里开始: 源Excel格式 enter image description here

为此: 目标格式 enter image description here

'OP_from_comment' = 'OP_from_post时,通过用'sound_bite_text'填充新列'original_post_text' '

Tag

我认为我应该创造2套;一个用于评论,一个用于原件和类似的在线示例会加入他们的行列,但返回错误

import pandas as pd

excel_file = 'test.xlsx'
data = pd.read_excel(excel_file)

original_posts = data[(data.post_type == "Original") & (data.source_type == "Facebook")]
comments = data[(data.post_type == "Replies and Comments") & (data.source_type == "Facebook")]

对我有用吗?

0 个答案:

没有答案
相关问题