st.map - autodetection of lat/long columns picks one out of the list
Checklist
- I have searched the existing issues for similar issues.
- I added a very descriptive title to this issue.
- I have provided sufficient information below to help reproduce this issue.
Summary
Hi,
stumbled across the ambiguity of the detecting of the geo columns for st.map.
current behavior: When users do not specify coordinate column, st.map looks for following columns:
_DEFAULT_LAT_COL_NAMES: Final = {"lat", "latitude", "LAT", "LATITUDE"} _DEFAULT_LON_COL_NAMES: Final = {"lon", "longitude", "LON", "LONGITUDE"}
.
Apparently, if the dataframe contains more than one of those columns, st.map picks one of them. This leads to different views per run, it can mix combinations.
Expectation would be that there is a warning / error in this case , instead of silently accepting the input.
`import streamlit as st import pandas as pd
Sample DataFrame with latitude, longitude, color, and size columns
data = { "latitude": [34.0522, 37.7749, 40.7128], "longitude": [-118.2437, -122.4194, -74.0060], "lat": [0, 0, 0], "lon": [-0, 0, 0], "size": [10, 20, 15], }
df = pd.DataFrame(data) st.map(df) `
Reproducible Code Example
import streamlit as st
import pandas as pd
# Sample DataFrame with latitude, longitude, color, and size columns
data = {
"latitude": [34.0522, 37.7749, 40.7128],
"longitude": [-118.2437, -122.4194, -74.0060],
"lat": [0, 0, 0],
"lon": [-0, 0, 0],
"size": [10, 20, 15],
}
df = pd.DataFrame(data)
st.map(df)
Steps To Reproduce
(lat,lon) is selected
(latitude,lon) is selected
(lat, longitude)
Expected Behavior
No response
Current Behavior
No response
Is this a regression?
- Yes, this used to work in a previous version.
Debug info
- Streamlit version:1.59.2
- Python version: 3.11.3
- Operating System: MacOS
- Browser: Chrome
Additional Information
No response
Source: streamlit/streamlit