Streamlit map displays additional unwanted data

Hi,
I hope I have not overseen anything but I have tried different adjustments and I still do not know how to solve it:
When displaying a map under st.map() the array containing the geocoordinates is displayed as well. See attachment:

I really do not know what I am doing wrong. Here a snippet of my code:

I just need the map to be displayed and not the array with the geocoordinates:

Any help will be appreciated.

Thanks,
Marcelo

Hi,

from the snippet above everything seems fine to me.
But could you also provide the input_request_prediction function?

Hi Alex,

Thank you for your support.
I have attached the the input_request_prediction function.
For your understanding, this is what the functions do:

  • It takes a country and city name as input
  • Out of the input the latitude and longitude is calculated (given as an array)
  • The above mentioned geo coordinates are used as an input to a K-Means algorithm which predicts to which cluster the coordinates belong.
  • The distances between every point in the cluster should be less than 200 Km; if that is the cases it finally returns a dataframe containing the geo coordinates of the cluster

The above logic is implemented for the origin and destination points, so that both returned dataframes are concatenated and given as input to the streamlit.map function which return the map showing the origin and destination clusters.

If needed I would not have a problem to send you the whole script and files to simulate the case.
Thank you again,

Marcelo

After sending me the whole script we found the issue. Here’s a snippet of the code causing the issue:

def my_function(df):

   df

   return df

new_df = my_function(df)

When calling the my_function, the call df within the function is used by streamlit to display the dataframe (even though there is no st.write or anything similar). To solve the issue, the corresponding line has to be removed/commented:

def my_function(df):

   # df

   return df

new_df = my_function(df)

Best, Alex

2 Likes