Skip to content

Instantly share code, notes, and snippets.

@doutv
Created June 26, 2023 07:42
Show Gist options
  • Save doutv/04c02a26194af0aab274b1a7890bd3f5 to your computer and use it in GitHub Desktop.
Save doutv/04c02a26194af0aab274b1a7890bd3f5 to your computer and use it in GitHub Desktop.
SeeDAO翻译公会:翻译库归档->统计贡献榜
# %%
import pandas as pd
df = pd.read_csv('db.csv')
# print(df.head())
print(df.columns)
# %%
df = df[["翻译","校对","信源","状态"]]
# remove trailing spaces from all columns
df = df.applymap(lambda x: x.strip() if isinstance(x, str) else x)
# %%
xinyuan = df[~df["状态"].isin([""])]["信源"].drop_duplicates()
fanyi = df[~df["状态"].isin(["待翻译", "翻译中", ""])]["翻译"].drop_duplicates()
jiaodui = df[~df["状态"].isin(["待翻译", "翻译中", "", "待校对", "校对中"])]["校对"].drop_duplicates()
users = pd.concat([xinyuan, fanyi, jiaodui], axis=0)
users = pd.unique(users)
new_df = pd.DataFrame({"成员":users})
print(new_df)
# %%
for col in ['信源', '翻译', '校对']:
for index, row in new_df.iterrows():
user = row['成员']
count = (df[col] == user).sum()
new_df.at[index, col] = count
print(new_df.head())
new_df.to_csv('contribution.csv', index=False, encoding='utf-8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment