Update year
Browse files- apps/grant.py +10 -1
- apps/journal.py +11 -2
- apps/organization.py +26 -16
- apps/publication.py +14 -8
apps/grant.py
CHANGED
@@ -4,10 +4,14 @@ import pandas as pd
|
|
4 |
import streamlit as st
|
5 |
import leafmap.foliumap as leafmap
|
6 |
import plotly.express as px
|
|
|
|
|
7 |
|
8 |
if "dsl" not in st.session_state:
|
9 |
st.session_state["dsl"] = scholarpy.Dsl()
|
10 |
|
|
|
|
|
11 |
|
12 |
def app():
|
13 |
st.title("Search Grants")
|
@@ -48,7 +52,12 @@ def app():
|
|
48 |
index=4,
|
49 |
)
|
50 |
with row1_col4:
|
51 |
-
years = st.slider(
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
with row1_col5:
|
54 |
limit = st.slider("Select the number of grants to return", 1, 1000, 100)
|
|
|
4 |
import streamlit as st
|
5 |
import leafmap.foliumap as leafmap
|
6 |
import plotly.express as px
|
7 |
+
import datetime
|
8 |
+
|
9 |
|
10 |
if "dsl" not in st.session_state:
|
11 |
st.session_state["dsl"] = scholarpy.Dsl()
|
12 |
|
13 |
+
current_year = datetime.datetime.now().year
|
14 |
+
|
15 |
|
16 |
def app():
|
17 |
st.title("Search Grants")
|
|
|
52 |
index=4,
|
53 |
)
|
54 |
with row1_col4:
|
55 |
+
years = st.slider(
|
56 |
+
"Select the start and end year:",
|
57 |
+
1950,
|
58 |
+
current_year + 6,
|
59 |
+
(2010, current_year + 4),
|
60 |
+
)
|
61 |
|
62 |
with row1_col5:
|
63 |
limit = st.slider("Select the number of grants to return", 1, 1000, 100)
|
apps/journal.py
CHANGED
@@ -6,6 +6,9 @@ import plotly.express as px
|
|
6 |
import streamlit as st
|
7 |
import scholarpy
|
8 |
import leafmap.foliumap as leafmap
|
|
|
|
|
|
|
9 |
|
10 |
if "dsl" not in st.session_state:
|
11 |
st.session_state["dsl"] = scholarpy.Dsl()
|
@@ -132,7 +135,10 @@ def app():
|
|
132 |
|
133 |
with row2_col5:
|
134 |
years = st.slider(
|
135 |
-
"Select the start and end year:",
|
|
|
|
|
|
|
136 |
)
|
137 |
|
138 |
if title:
|
@@ -189,7 +195,10 @@ def app():
|
|
189 |
|
190 |
with row1_col3:
|
191 |
years = st.slider(
|
192 |
-
"Select the start and end year:",
|
|
|
|
|
|
|
193 |
)
|
194 |
|
195 |
if journal:
|
|
|
6 |
import streamlit as st
|
7 |
import scholarpy
|
8 |
import leafmap.foliumap as leafmap
|
9 |
+
import datetime
|
10 |
+
|
11 |
+
current_year = datetime.datetime.now().year
|
12 |
|
13 |
if "dsl" not in st.session_state:
|
14 |
st.session_state["dsl"] = scholarpy.Dsl()
|
|
|
135 |
|
136 |
with row2_col5:
|
137 |
years = st.slider(
|
138 |
+
"Select the start and end year:",
|
139 |
+
1950,
|
140 |
+
current_year,
|
141 |
+
(1980, current_year),
|
142 |
)
|
143 |
|
144 |
if title:
|
|
|
195 |
|
196 |
with row1_col3:
|
197 |
years = st.slider(
|
198 |
+
"Select the start and end year:",
|
199 |
+
1950,
|
200 |
+
current_year,
|
201 |
+
(1980, current_year),
|
202 |
)
|
203 |
|
204 |
if journal:
|
apps/organization.py
CHANGED
@@ -4,6 +4,9 @@ import pandas as pd
|
|
4 |
import streamlit as st
|
5 |
import leafmap.foliumap as leafmap
|
6 |
import plotly.express as px
|
|
|
|
|
|
|
7 |
|
8 |
if "dsl" not in st.session_state:
|
9 |
st.session_state["dsl"] = scholarpy.Dsl()
|
@@ -19,8 +22,7 @@ def app():
|
|
19 |
name = st.text_input("Enter an organization name:", "")
|
20 |
|
21 |
if name:
|
22 |
-
orgs = dsl.search_org_by_name(
|
23 |
-
name, exact_match=False, return_list=True)
|
24 |
|
25 |
if orgs is not None:
|
26 |
with row1_col1:
|
@@ -31,8 +33,7 @@ def app():
|
|
31 |
|
32 |
info_df = scholarpy.json_to_df(id_info, transpose=True)
|
33 |
info_df.rename(
|
34 |
-
columns={info_df.columns[0]: "Type",
|
35 |
-
info_df.columns[1]: "Value"},
|
36 |
inplace=True,
|
37 |
)
|
38 |
with row1_col1:
|
@@ -47,14 +48,18 @@ def app():
|
|
47 |
|
48 |
with row1_col2:
|
49 |
years = st.slider(
|
50 |
-
"Select the start and end year:",
|
|
|
|
|
|
|
|
|
51 |
st.header("Publications by year")
|
52 |
|
53 |
pubs, fig = dsl.org_pubs_annual_stats(
|
54 |
-
org_id, start_year=years[0], end_year=years[1], return_plot=True
|
|
|
55 |
|
56 |
-
st.text(
|
57 |
-
f'Total number of publications: {pubs["count"].sum():,}')
|
58 |
|
59 |
if fig is not None:
|
60 |
st.plotly_chart(fig)
|
@@ -72,12 +77,13 @@ def app():
|
|
72 |
st.header("Top funders")
|
73 |
|
74 |
funder_count = st.slider(
|
75 |
-
"Select the number of funders:", 1, 100, 20
|
|
|
76 |
|
77 |
funders, fig = dsl.org_grant_funders(
|
78 |
-
org_id, limit=funder_count, return_plot=True
|
79 |
-
|
80 |
-
|
81 |
if fig is not None:
|
82 |
st.plotly_chart(fig)
|
83 |
leafmap.st_download_button(
|
@@ -92,7 +98,8 @@ def app():
|
|
92 |
with row1_col2:
|
93 |
st.header("The number of grants by year")
|
94 |
grants, fig_count, fig_amount = dsl.org_grants_annual_stats(
|
95 |
-
org_id, start_year=years[0], end_year=years[1], return_plot=True
|
|
|
96 |
|
97 |
st.plotly_chart(fig_count)
|
98 |
st.plotly_chart(fig_amount)
|
@@ -107,7 +114,8 @@ def app():
|
|
107 |
st.header("List of grants")
|
108 |
st.text("Only the first 1000 grants are shown")
|
109 |
result = dsl.search_grants_by_org(
|
110 |
-
org_id, start_year=years[0], end_year=years[1]
|
|
|
111 |
df = result.as_dataframe()
|
112 |
if not df.empty:
|
113 |
st.dataframe(df)
|
@@ -135,7 +143,9 @@ def app():
|
|
135 |
"Download data", df, file_name="data.csv", csv_sep="\t"
|
136 |
)
|
137 |
|
138 |
-
df, area_fig, journal_fig = dsl.org_pubs_top_areas(
|
|
|
|
|
139 |
if not df.empty:
|
140 |
with row1_col1:
|
141 |
st.header("Research areas of most cited publications")
|
@@ -145,7 +155,7 @@ def app():
|
|
145 |
# )
|
146 |
with row1_col2:
|
147 |
st.header("Journals of most cited publications")
|
148 |
-
st.plotly_chart(journal_fig)
|
149 |
leafmap.st_download_button(
|
150 |
"Download data", df, file_name="data.csv", csv_sep="\t"
|
151 |
)
|
|
|
4 |
import streamlit as st
|
5 |
import leafmap.foliumap as leafmap
|
6 |
import plotly.express as px
|
7 |
+
import datetime
|
8 |
+
|
9 |
+
current_year = datetime.datetime.now().year
|
10 |
|
11 |
if "dsl" not in st.session_state:
|
12 |
st.session_state["dsl"] = scholarpy.Dsl()
|
|
|
22 |
name = st.text_input("Enter an organization name:", "")
|
23 |
|
24 |
if name:
|
25 |
+
orgs = dsl.search_org_by_name(name, exact_match=False, return_list=True)
|
|
|
26 |
|
27 |
if orgs is not None:
|
28 |
with row1_col1:
|
|
|
33 |
|
34 |
info_df = scholarpy.json_to_df(id_info, transpose=True)
|
35 |
info_df.rename(
|
36 |
+
columns={info_df.columns[0]: "Type", info_df.columns[1]: "Value"},
|
|
|
37 |
inplace=True,
|
38 |
)
|
39 |
with row1_col1:
|
|
|
48 |
|
49 |
with row1_col2:
|
50 |
years = st.slider(
|
51 |
+
"Select the start and end year:",
|
52 |
+
1950,
|
53 |
+
current_year + 6,
|
54 |
+
(1980, current_year),
|
55 |
+
)
|
56 |
st.header("Publications by year")
|
57 |
|
58 |
pubs, fig = dsl.org_pubs_annual_stats(
|
59 |
+
org_id, start_year=years[0], end_year=years[1], return_plot=True
|
60 |
+
)
|
61 |
|
62 |
+
st.text(f'Total number of publications: {pubs["count"].sum():,}')
|
|
|
63 |
|
64 |
if fig is not None:
|
65 |
st.plotly_chart(fig)
|
|
|
77 |
st.header("Top funders")
|
78 |
|
79 |
funder_count = st.slider(
|
80 |
+
"Select the number of funders:", 1, 100, 20
|
81 |
+
)
|
82 |
|
83 |
funders, fig = dsl.org_grant_funders(
|
84 |
+
org_id, limit=funder_count, return_plot=True
|
85 |
+
)
|
86 |
+
st.text(f'Total funding amount: ${funders["funding"].sum():,}')
|
87 |
if fig is not None:
|
88 |
st.plotly_chart(fig)
|
89 |
leafmap.st_download_button(
|
|
|
98 |
with row1_col2:
|
99 |
st.header("The number of grants by year")
|
100 |
grants, fig_count, fig_amount = dsl.org_grants_annual_stats(
|
101 |
+
org_id, start_year=years[0], end_year=years[1], return_plot=True
|
102 |
+
)
|
103 |
|
104 |
st.plotly_chart(fig_count)
|
105 |
st.plotly_chart(fig_amount)
|
|
|
114 |
st.header("List of grants")
|
115 |
st.text("Only the first 1000 grants are shown")
|
116 |
result = dsl.search_grants_by_org(
|
117 |
+
org_id, start_year=years[0], end_year=years[1]
|
118 |
+
)
|
119 |
df = result.as_dataframe()
|
120 |
if not df.empty:
|
121 |
st.dataframe(df)
|
|
|
143 |
"Download data", df, file_name="data.csv", csv_sep="\t"
|
144 |
)
|
145 |
|
146 |
+
df, area_fig, journal_fig = dsl.org_pubs_top_areas(
|
147 |
+
org_id, return_plot=True
|
148 |
+
)
|
149 |
if not df.empty:
|
150 |
with row1_col1:
|
151 |
st.header("Research areas of most cited publications")
|
|
|
155 |
# )
|
156 |
with row1_col2:
|
157 |
st.header("Journals of most cited publications")
|
158 |
+
st.plotly_chart(journal_fig)
|
159 |
leafmap.st_download_button(
|
160 |
"Download data", df, file_name="data.csv", csv_sep="\t"
|
161 |
)
|
apps/publication.py
CHANGED
@@ -4,6 +4,9 @@ import pandas as pd
|
|
4 |
import streamlit as st
|
5 |
import leafmap.foliumap as leafmap
|
6 |
import plotly.express as px
|
|
|
|
|
|
|
7 |
|
8 |
if "dsl" not in st.session_state:
|
9 |
st.session_state["dsl"] = scholarpy.Dsl()
|
@@ -46,7 +49,12 @@ def app():
|
|
46 |
)
|
47 |
|
48 |
with row1_col4:
|
49 |
-
years = st.slider(
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
with row1_col5:
|
52 |
limit = st.slider("Select the number of publications to return", 1, 1000, 100)
|
@@ -63,11 +71,11 @@ def app():
|
|
63 |
|
64 |
df = scholarpy.json_to_df(result)
|
65 |
affiliations = result.as_dataframe_authors_affiliations()
|
66 |
-
country_df = affiliations.groupby([
|
67 |
-
df = df.merge(country_df, left_on=
|
68 |
|
69 |
-
countries = [c[c.astype(bool)].size for c in df[
|
70 |
-
df[
|
71 |
|
72 |
journal_counts = df.copy()["journal.title"].value_counts()
|
73 |
if limit > result.count_total:
|
@@ -116,7 +124,5 @@ def app():
|
|
116 |
leafmap.st_download_button("Download data", summary, csv_sep="\t")
|
117 |
|
118 |
with row3_col2:
|
119 |
-
fig = px.box(df, x=
|
120 |
st.plotly_chart(fig)
|
121 |
-
|
122 |
-
|
|
|
4 |
import streamlit as st
|
5 |
import leafmap.foliumap as leafmap
|
6 |
import plotly.express as px
|
7 |
+
import datetime
|
8 |
+
|
9 |
+
current_year = datetime.datetime.now().year
|
10 |
|
11 |
if "dsl" not in st.session_state:
|
12 |
st.session_state["dsl"] = scholarpy.Dsl()
|
|
|
49 |
)
|
50 |
|
51 |
with row1_col4:
|
52 |
+
years = st.slider(
|
53 |
+
"Select the start and end year:",
|
54 |
+
1950,
|
55 |
+
current_year + 6,
|
56 |
+
(1980, current_year),
|
57 |
+
)
|
58 |
|
59 |
with row1_col5:
|
60 |
limit = st.slider("Select the number of publications to return", 1, 1000, 100)
|
|
|
71 |
|
72 |
df = scholarpy.json_to_df(result)
|
73 |
affiliations = result.as_dataframe_authors_affiliations()
|
74 |
+
country_df = affiliations.groupby(["pub_id"])["aff_country"].unique()
|
75 |
+
df = df.merge(country_df, left_on="id", right_on="pub_id")
|
76 |
|
77 |
+
countries = [c[c.astype(bool)].size for c in df["aff_country"]]
|
78 |
+
df["country_count"] = countries
|
79 |
|
80 |
journal_counts = df.copy()["journal.title"].value_counts()
|
81 |
if limit > result.count_total:
|
|
|
124 |
leafmap.st_download_button("Download data", summary, csv_sep="\t")
|
125 |
|
126 |
with row3_col2:
|
127 |
+
fig = px.box(df, x="year", y="country_count", title="Country Counts")
|
128 |
st.plotly_chart(fig)
|
|
|
|