singhsidhukuldeep
commited on
Commit
β’
a1d5d83
1
Parent(s):
442b62f
Update app.py
Browse files
app.py
CHANGED
@@ -7,32 +7,42 @@ st.set_page_config(layout="wide")
|
|
7 |
st.header("HuggingFace π€ Posts leaderboard")
|
8 |
|
9 |
st.write(
|
10 |
-
"""Data Source: https://huggingface.co/datasets/maxiw/hf-posts
|
11 |
)
|
12 |
|
13 |
df = pd.read_json("hf://datasets/maxiw/hf-posts/posts.jsonl", lines=True)
|
14 |
|
15 |
df["publishedAt"] = pd.to_datetime(df.publishedAt)
|
16 |
-
print(df.columns)
|
|
|
|
|
|
|
|
|
17 |
|
18 |
# Get min and max dates from the DataFrame
|
19 |
min_date = df["publishedAt"].min().to_pydatetime()
|
20 |
max_date = df["publishedAt"].max().to_pydatetime()
|
21 |
|
22 |
-
# Create the
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
# Filter the DataFrame based on selected date range
|
37 |
mask = df["publishedAt"].between(*date_range)
|
38 |
df = df[mask]
|
|
|
7 |
st.header("HuggingFace π€ Posts leaderboard")
|
8 |
|
9 |
st.write(
|
10 |
+
"""Data Source: https://huggingface.co/datasets/maxiw/hf-posts"""
|
11 |
)
|
12 |
|
13 |
df = pd.read_json("hf://datasets/maxiw/hf-posts/posts.jsonl", lines=True)
|
14 |
|
15 |
df["publishedAt"] = pd.to_datetime(df.publishedAt)
|
16 |
+
# print(df.columns)
|
17 |
+
|
18 |
+
# Define the metrics
|
19 |
+
metrics = ["totalUniqueImpressions", "totalReactions", "numComments", "Num of posts"]
|
20 |
+
|
21 |
|
22 |
# Get min and max dates from the DataFrame
|
23 |
min_date = df["publishedAt"].min().to_pydatetime()
|
24 |
max_date = df["publishedAt"].max().to_pydatetime()
|
25 |
|
26 |
+
# Create columns for the slider and the selectbox
|
27 |
+
col1, col2 = st.columns([3, 1]) # Adjust the width ratio as needed
|
28 |
+
|
29 |
+
with col1:
|
30 |
+
date_range = st.slider(
|
31 |
+
"Select Date Range",
|
32 |
+
min_value=min_date,
|
33 |
+
max_value=max_date,
|
34 |
+
value=(min_date, max_date),
|
35 |
+
format="DD/MMM/YYYY",
|
36 |
+
)
|
37 |
+
|
38 |
+
with col2:
|
39 |
+
selected_metric = st.selectbox(
|
40 |
+
"Sort by:",
|
41 |
+
options=metrics,
|
42 |
+
index=0,
|
43 |
+
)
|
44 |
+
|
45 |
+
|
46 |
# Filter the DataFrame based on selected date range
|
47 |
mask = df["publishedAt"].between(*date_range)
|
48 |
df = df[mask]
|