Spaces:
Runtime error
Runtime error
add upvotes filter
Browse files
app.py
CHANGED
@@ -8,8 +8,9 @@ st.markdown("<h1 style='text-align: center; color: #00BFFF;'>Kaggle Notebooks in
|
|
8 |
|
9 |
st.markdown("Here you can inspect Kaggle notebooks that were converted to python scripts and deduplicated.")
|
10 |
@st.cache()
|
11 |
-
def load_data():
|
12 |
ds = load_dataset("loubnabnl/subset_kaggle_scripts", split="train")
|
|
|
13 |
return ds
|
14 |
|
15 |
def show_extra_info(e):
|
@@ -29,7 +30,10 @@ def show_extra_info(e):
|
|
29 |
text = f"The title of the notebook is: **{kv['Title']}** and it has **{kv['TotalVotes']} ⬆️ upvotes**.{data_text}"
|
30 |
return text
|
31 |
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
34 |
st.markdown(show_extra_info(samples[index_example]), unsafe_allow_html=True)
|
35 |
st.code(samples[index_example]["script"])
|
|
|
8 |
|
9 |
st.markdown("Here you can inspect Kaggle notebooks that were converted to python scripts and deduplicated.")
|
10 |
@st.cache()
|
11 |
+
def load_data(upvote=0):
|
12 |
ds = load_dataset("loubnabnl/subset_kaggle_scripts", split="train")
|
13 |
+
ds = ds.filter(lambda x: x["upvotes"] >= upvote)
|
14 |
return ds
|
15 |
|
16 |
def show_extra_info(e):
|
|
|
30 |
text = f"The title of the notebook is: **{kv['Title']}** and it has **{kv['TotalVotes']} ⬆️ upvotes**.{data_text}"
|
31 |
return text
|
32 |
|
33 |
+
|
34 |
+
vote = st.sidebar.slider("Minimum notebook ⬆️ upvotes", min_value=0, max_value=100, step=1, value=0)
|
35 |
+
samples = load_data(vote)
|
36 |
+
index_example = st.sidebar.number_input(f"Choose a sample from the existing {len(samples)} notebooks:", min_value=0, max_value=max(0, len(samples)-1), value=0, step=1)
|
37 |
+
|
38 |
st.markdown(show_extra_info(samples[index_example]), unsafe_allow_html=True)
|
39 |
st.code(samples[index_example]["script"])
|