Importing Pandas as pd
See original GitHub issueSummary
I am attempting to create a few different pages, but I am having trouble importing pandas when also importing streamlit commands from a function.
Steps to reproduce
Main.py
import streamlit as st
import pandas as pd
import sqlite3
from Title import entry_form
# ######### Database ##########
conn = sqlite3.connect(r"G:\General\Solar\R_and_D\CodeLibrary\Python\CRUD\Database\data.db")
c = conn.cursor()
# ######### Menu ###################
menu_list = ['Title', 'Climate', 'Design', 'Layout', 'Performance']
choice = st.sidebar.radio(label='Menu',
options=menu_list)
# ########## Title Page ##########
if choice == 'Title':
entry_form()
Title.py
import streamlit as st
import pandas as pd
from Sqlite import *
def entry_form():
"""
User form to choose or upload a new solar project
"""
import pandas as pd
st.title("User Entry Form")
region_list = ['West', 'South', 'East']
region = st.selectbox('Region', region_list, index=0)
df = pd.read_sql_query("SELECT * from projtable", conn)
df = df.where(df['region'] == region).dropna()
st.subheader('Project Entry')
project_list = list(df['project'])
project_list.sort()
project = st.selectbox('Project', project_list)
project_new = st.text_input('New Project Name')
if project_new != '':
project = project_new
df = df.where(df['project'] == project).dropna()
st.subheader('Version Control')
version_list = list(df['version'])
version_list.sort()
version = st.selectbox('Version', version_list)
version_new = st.text_input('New Version')
if version_new != '':
version = version_new
st.subheader('User')
user_list = ['Angel_Velasco',
'Cameron_Nielsen',
'James_Alfi',
'Kurt_Rhee',
'Marine_Bila',
'Phil_Timm']
user = st.selectbox('Username', user_list, index=3)
if st.button('Add'):
create_table()
add_data(user, region, project, version)
st.success('Project Saved')
df
Expected behavior:
I would expect that importing pandas in the Title.py scipt would not give a NameError pd is not defined
Actual behavior:
Is this a regression?
I have not tried this in previous versions.
Debug info
- Streamlit version: 0.62.0
- Python version: 3.7
- Using Conda
- OS version: Windows 10
- Browser version: Chrome
Additional information
N/A
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
The Easiest Way to Use Pandas in Python: import pandas as pd
The Easiest Way to Use Pandas in Python: import pandas as pd ... pandas is an open source data analysis library built on...
Read more >Pandas Getting Started - W3Schools
Pandas as pd ... Pandas is usually imported under the pd alias. alias: In Python alias are an alternate name for referring to...
Read more >10 minutes to pandas — pandas 1.5.2 documentation
This is a short introduction to pandas, geared mainly for new users. You can see more complex recipes in the Cookbook. Customarily, we...
Read more >Import Pandas as pd. Basics of pandas in layman term - Medium
Import Pandas. If you want to use the Pandas module in your working path. Just import it with the following command. It is...
Read more >What is pandas in Python? - Educative.io
pandas (all lowercase) is a popular Python-based data analysis toolkit which can be imported using import pandas as pd . It presents a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nthmost Hey, I’ve been upgrading streamlit as new versions come out and haven’t had this issue again. I think the solution may just be to update if people are still using 0.62.
I think this is safe to close.
Hi @kurt-rhee – is there a simplified repro you can provide for this bug? I.e. the shortest possible script that produces this error. It seems pretty mysterious and I haven’t been able to repro it myself yet.