mteb

Форк
0
/
create_points_table.py 
40 строк · 1.1 Кб
1
import json
2
from pathlib import Path
3

4
import pandas as pd
5

6

7
def load_data(file_path: Path) -> pd.DataFrame:
8
    file_path = Path(__file__).parent / "points"
9
    files = file_path.glob("*.jsonl")
10

11
    json_data = []
12
    for file in files:
13
        with open(file) as f:
14
            for line in f:
15
                json_data.append(json.loads(line))
16

17
    df = pd.DataFrame(json_data)
18
    return df
19

20

21
def save_to_markdown(df: pd.DataFrame, file_path: Path) -> None:
22
    df = df.groupby("GitHub").sum().astype(int)
23
    # create a new column with the sum of the points
24
    df["Total"] = df.sum(axis=1)
25
    # sort the dataframe by the total points
26
    df = df.sort_values("Total", ascending=False)
27

28
    md = df.to_markdown()
29
    # add title
30
    md = f"# Points\n\n_Note_: this table is **autogenerated** and should not be edited. It is intended to get an overview of contributions.\n\n {md}"
31
    with open(file_path, "w") as f:
32
        f.write(md)
33

34

35
if __name__ == "__main__":
36
    file_path = Path(__file__).parent / "points"
37
    save_path = Path(__file__).parent / "points_table.md"
38

39
    df = load_data(file_path)
40
    save_to_markdown(df, save_path)
41

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.