可以通过以下步骤实现:
import pandas as pd
data = pd.read_csv('关系表.csv')
mutual_followers = pd.DataFrame(columns=['User', 'Mutual Followers'])
for index, row in data.iterrows():
user = row['User']
followers = row['Followers']
following = row['Following']
mutual_count = len(set(followers) & set(following))
mutual_followers = mutual_followers.append({'User': user, 'Mutual Followers': mutual_count}, ignore_index=True)
mutual_followers = mutual_followers.sort_values(by='Mutual Followers', ascending=False)
print(mutual_followers.head())
这样就可以使用pandas统计关系表中的相互关注人数了。
关于pandas的更多信息和使用方法,可以参考腾讯云的产品介绍链接:腾讯云-数据分析与AI-数据处理与分析-Pandas
领取专属 10元无门槛券
手把手带您无忧上云