我想计算数据集中发生的三向对话的数量。聊天group_x可以由多个成员组成。
什么是三方对话?
red_x 在 group_x 中发送消息。green_x 在同一组_x 中回复。red_x 在同一个 group_x 中发送回复。这可以称为三方对话。
序列必须恰好是 red_#、green_#、red_#。
什么是接触点?
用于轻松生成我正在使用的示例数据集的代码。
import pandas as pd
from pandas import Timestamp
t1_df = pd.DataFrame({'from_red': [True, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, True],
'sent_time': [Timestamp('2021-05-01 06:26:00'), Timestamp('2021-05-04 10:35:00'), …Run Code Online (Sandbox Code Playgroud) import pandas as pd
import numpy as np
time = ['11:50', '12:50', '13:50']
data_1 = {'time': time,
'n1': [1, 5, 8],
'n2': [2, 6 ,7],
'n3': [3, 7 ,6],
'n4': [4, 8, 5],
}
df1 = pd.DataFrame(data = data_1)
df1
Run Code Online (Sandbox Code Playgroud)
我正在尝试乘以:
前:
| 时间 | n1 | n2 | n3 | n4 | |
|---|---|---|---|---|---|
| 0 | 11点50分 | 1 | 2 | 3 | 4 |
| 1 | 12:50 | 5 |
6 |
7 … |
我正在尝试创建 a 列和 b 列中有数百个项目的列,并且我想删除 b 列中的常见项目并将它们列出在 Excel 或 google 工作表的不同列中。
| A | 乙 | 仅 b 列中存在的项目 |
|---|---|---|
| a1 | a1 | a5 |
| a2 | a2 | a6 |
| a3 | a5 |
|
| a4 | a6 |