File size: 1,588 Bytes
3e996d0
e6ac219
eccb5e1
932e360
 
860b3ba
 
932e360
fce2a17
 
e6ac219
 
 
860b3ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fce2a17
860b3ba
 
 
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
import streamlit as st
import pandas as pd
import numpy as np
import requests

# Function to fetch data from the Apify actor
def fetch_data_from_apify_actor(url):
    response = requests.get(url)
    return response.json()

# Streamlit app
st.title("Data Visualization")

# Fetch data using Apify actor
apify_actor_url = "https://api.apify.com/v2/actor-runs/HsejBCDbeF39qAgsa?token=apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp"
data = fetch_data_from_apify_actor(apify_actor_url)
google_maps_data = data.get('output', {}).get('data', {})

if google_maps_data:
    # Display website link in a specific output box
    website_link = google_maps_data.get('website')
    st.text_area("Website Link:", website_link)

    # Occupancy Data: Aggregate and rank
    st.subheader("Occupancy Data (Aggregated by Day)")
    occupancy_data = google_maps_data.get('popularTimesHistogram', {})
    avg_occupancy = {}
    for day, day_data in occupancy_data.items():
        if day_data:
            avg_occupancy[day] = np.mean([entry['occupancyPercent'] for entry in day_data])
    days_order = sorted(avg_occupancy, key=avg_occupancy.get, reverse=True)
    st.bar_chart(pd.Series({day: avg_occupancy[day] for day in days_order}), use_container_width=True)
    
    # Reviews Table
    st.subheader("Customer Reviews")
    reviews = google_maps_data.get('reviews', [])
    if reviews:
        review_df = pd.DataFrame(reviews)
        st.table(review_df[['name', 'text', 'publishAt', 'likesCount', 'stars']])
    else:
        st.write("No reviews available.")
else:
    st.write("No results found.")