File size: 3,304 Bytes
c8e0175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import streamlit as st
import pandas as pd

def show_single_table(result_df):

    result_df = result_df.reset_index(drop=True)

    # Transformations
    result_df["crs_3_code_list"] = result_df['crs_3_code'].str.split(";").apply(lambda x: x[:-1] if x else [])
    result_df["crs_5_code_list"] = result_df['crs_5_code'].str.split(";").apply(lambda x: x[:-1] if x else [])  
    result_df["sdg_list"] = result_df['sgd_pred_code'].apply(lambda x: [x] if pd.notna(x) else [])
    result_df["flag"] = result_df['country'].apply(lambda x: f"https://flagicons.lipis.dev/flags/4x3/{x[:2].lower()}.svg" if pd.notna(x) else "https://flagicons.lipis.dev/flags/4x3/xx.svg")
        
    st.dataframe(
        result_df[["similarity", "iati_id", "title_main", "orga_abbreviation", "client", "description_main", "country", "flag", "sdg_list", "crs_3_code_list", "crs_5_code_list"]],
        use_container_width = True,
        height = 35 + 35 * len(result_df),
        column_config={
            "similarity": st.column_config.TextColumn(
                "Similarity",
                help="similarity to selected project",
                disabled=True,
                width="small"
            ),
            "iati_id": st.column_config.TextColumn(
                "IATI ID",
                help="IATI Project ID",
                disabled=True,
                width="small"
            ),
            "orga_abbreviation": st.column_config.TextColumn(
                "Organization",
                help="If description not in English, description in other language provided",
                disabled=True,
                width="small"
            ),
            "client": st.column_config.TextColumn(
                "Client",
                help="Client organization of customer",
                disabled=True,
                width="small"
            ),
            "title_main": st.column_config.TextColumn(
                "Title",
                help="If title not in English, title in other language provided",
                disabled=True,
                width="large"
            ),
            "description_main": st.column_config.TextColumn(
                "Description",
                help="If description not in English, description in other language provided",
                disabled=True,
                width="large"
            ),
            "country": st.column_config.TextColumn(
                "Country",
                help="Country of project",
                disabled=True,
                width="small"
            ),
            "flag": st.column_config.ImageColumn(
                "Flag",
                help="country flag",
                width="small"
            ),
            "sdg_list": st.column_config.ListColumn(
                "SDG Prediction",
                help="Prediction of SDG's",
                width="small"
            ),
            "crs_3_code_list": st.column_config.ListColumn(
                "CRS 3",
                help="CRS 3 code given by organization",
                width="small"
            ),
            "crs_5_code_list": st.column_config.ListColumn(
                "CRS 5",
                help="CRS 5 code given by organization",
                width="small"
            ),
        },
        hide_index=True,
    )