0

I am a beginner and trying to visualize some data with Pydeck. My problem is, it only shows the background map and no data. I would like to visualize the prices of the Air BnBs in Berlin.

Maybe someone can help? Thanks!

The data is retrieved from: https://www.kaggle.com/code/lennarthaupts/airbnb-prices-in-berlin/data

import streamlit as st
import pydeck as pdk

st.title("Air BnB Berlin 07/2021")


#data
in_csv = "listings_berlin.csv"


#layer
layer1 = pdk.Layer(
    'ColumnLayer', 
    in_csv,
    get_position=['longitude', 'latitude'],
    auto_highlight=True,
    elevation_scale=50,
    pickable=True,
    elevation_range=[0, 3000],
    extruded=True,
    coverage=1)


# Set viewport location to Berlin
view_state = pdk.ViewState(
    longitude=13.4,
    latitude=52.5,
    zoom=6,
    min_zoom=5,
    max_zoom=15,
    pitch=40.5,
    bearing=-27.36)

# render
air = pdk.Deck(layers=[layer1], initial_view_state=view_state)
air

Thanks!

1 Answer 1

1

About the data:

For some reason the download link on the Kaggle website was unresponsive.

I looked for the data and found it on the inside AirBNB website.

Looks like there are some NaNs which causes the script to fail.

I created a new csv file with just part of the coordinates to test my code.

import streamlit as st
import pydeck as pdk
import pandas as pd

#data
in_csv = "part1.csv"

listings_df = pd.read_csv(in_csv)


st.pydeck_chart(
    pdk.Deck(
        map_style="mapbox://styles/mapbox/light-v9",
        initial_view_state=pdk.ViewState(
        latitude=52.5,
        longitude=13.4,
        zoom=10
        ),
        layers=[
            pdk.Layer(
                "ScatterplotLayer",
                data=listings_df,
                get_position=["longitude", "latitude"],
                get_color=[200,20,20],
                get_radius=120
            )
        ],
    )
)

This is the map with some of the listings in red.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.