singhsidhukuldeep commited on
Commit
a1d5d83
β€’
1 Parent(s): 442b62f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -16
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 \t Created by: https://huggingface.co/singhsidhukuldeep"""
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 double-ended slider
23
- date_range = st.slider(
24
- "Select Date Range",
25
- min_value=min_date,
26
- max_value=max_date,
27
- value=(min_date, max_date),
28
- format="DD/MMM/YYYY",
29
- )
30
- metrics = ["totalUniqueImpressions", "totalReactions", "numComments", "Num of posts"]
31
- selected_metric = st.selectbox(
32
- "Sort by:",
33
- options=metrics,
34
- index=0,
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]