awacke1's picture
Create app.py
f0de933 verified
raw
history blame
7.16 kB
# How can I add row to an iterable dataset
#πŸ€—Datasets
#This is the first time xbilek25 has posted β€” let’s welcome them to our community!
#xbilek25
#2
#9h
#I need any working option to add row to a dataset, where streaming=True. While working with normal dataset I define new item and use code like this:
#tmp_dataset = tmp_dataset.add_item(new_item), but i can’t figure out how to do this while my dataset is streaming=True.
#Can anyone help me to find solution, please?
if st.checkbox('Show Anatomy Table'):
st.markdown("""
## Anatomy Head to Toe Table with Body Organs Costly Conditions, Spending, CPT Codes and Frequency
| Table Num | Body Part | Organ/Part | Description | πŸ“ˆ Costly Condition | πŸ’° Spending (billions) | CPT Range Start | CPT Range Finish | Frequency |
|-----------|------------------|----------------------|-------------------------------|------------------------------|------------------------|-----------------|------------------|----------------|
| 1 | 🧠 Head | 🧠 Brain | Controls mental processes | 😨 Anxiety & Depression | 210 | 90791 | 90899 | 1 in 5 |
| 2 | πŸ‘€ Eyes | πŸ‘οΈ Optic Nerve | Vision | πŸ‘“ Cataracts | 10.7 | 92002 | 92499 | 1 in 6 (over 40 years) |
| 3 | πŸ‘‚ Ears | 🐚 Cochlea | Hearing | πŸ“’ Hearing Loss | 7.1 | 92502 | 92700 | 1 in 8 (over 12 years) |
| 4 | πŸ‘ƒ Nose | πŸ‘ƒ Olfactory Bulb | Smell | 🀧 Allergies | 25 | 31231 | 31294 | 1 in 3 |
| 5 | πŸ‘„ Mouth | πŸ‘… Tongue | Taste | 🦷 Dental Issues | 130 | 00100 | 00192 | 1 in 2 |
| 6 | 🫁 Neck | πŸ¦‹ Thyroid | Metabolism | 🦠 Hypothyroidism | 3.1 | 60210 | 60271 | 1 in 20 |
| 7 | πŸ’ͺ Upper Body | ❀️ Heart | Circulation | πŸ’” Heart Disease | 230 | 92920 | 93799 | 1 in 4 (over 65 years) |
| 8 | πŸ’ͺ Upper Body | 🫁 Lungs | Respiration | 😷 Chronic Obstructive Pulmonary Disease | 70 | 94002 | 94799 | 1 in 20 (over 45 years) |
| 9 | πŸ’ͺ Upper Body | 🍷 Liver | Detoxification | 🍺 Liver Disease | 40 | 47000 | 47999 | 1 in 10 |
| 10 | πŸ’ͺ Upper Body | 🍹 Kidneys | Filtration | 🌊 Chronic Kidney Disease | 110 | 50010 | 50999 | 1 in 7 |
| 11 | πŸ’ͺ Upper Body | πŸ’‰ Pancreas | Insulin secretion | 🍬 Diabetes | 327 | 48100 | 48999 | 1 in 10 |
| 12 | πŸ’ͺ Upper Body | 🍽️ Stomach | Digestion | πŸ”₯ Gastroesophageal Reflux Disease | 17 | 43200 | 43289 | 1 in 5 |
| 13 | πŸ’ͺ Upper Body | πŸ›‘οΈ Spleen | Immune functions | 🩸 Anemia | 5.6 | 38100 | 38199 | 1 in 6 |
| 14 | πŸ’ͺ Upper Body | πŸ«€ Blood Vessels | Circulation of blood | πŸš‘ Hypertension | 55 | 40110 | 40599 | 1 in 3 |
| 15 | 🦡 Lower Body | 🍝 Colon | Absorption of water, minerals | 🌟 Colorectal Cancer | 14 | 45378 | 45378 | 1 in 23 |
| 16 | 🦡 Lower Body | 🚽 Bladder | Urine excretion | πŸ’§ Urinary Incontinence | 8 | 51700 | 51798 | 1 in 4 (over 65 years) |
| 17 | 🦡 Lower Body | πŸ’ž Reproductive Organs | Sex hormone secretion | πŸŽ—οΈ Endometriosis | 22 | 56405 | 58999 | 1 in 10 (women) |
| 18 | 🦢 Feet | 🎯 Nerve endings | Balance and movement | πŸ€• Peripheral Neuropathy | 19 | 95900 | 96004 | 1 in 30 |
| 19 | 🦢 Feet | 🌑️ Skin | Temperature regulation | 🌞 Skin Cancer | 8.1 | 96910 | 96999 | 1 in 5 |
| 20 | 🦢 Feet | πŸ’ͺ Muscles | Movement and strength | πŸ‹οΈβ€β™‚οΈ Musculoskeletal Disorders | 176 | 97110 | 97799 | 1 in 2 |
""")
import streamlit as st
import pandas as pd
# Load dataset
def load_data():
return pd.read_csv('anatomy_dataset.csv')
# Save dataset
def save_data(df):
df.to_csv('anatomy_dataset.csv', index=False)
# CRUD Operations
def add_data(df):
# Add a row to the dataframe (Example)
# You can modify this function to take input from the user
new_row = {'Table Num': 21, 'Body Part': 'New Part', 'Organ/Part': 'New Organ', 'Description': 'New Description',
'Costly Condition': 'New Condition', 'Spending (billions)': 0, 'CPT Range Start': 0, 'CPT Range Finish': 0,
'Frequency': 'New Frequency'}
df = df.append(new_row, ignore_index=True)
return df
def update_data(df):
# Update a row in the dataframe (Example)
# Implement the update logic based on your requirements
if not df.empty:
df.at[0, 'Description'] = 'Updated Description'
return df
def delete_data(df):
# Delete a row from the dataframe (Example)
# Implement the delete logic based on your requirements
if not df.empty:
df = df.drop(df.index[0])
return df
# Streamlit UI
st.title("Anatomy Head to Toe CRUD Operations")
# Display the table if checkbox is checked
if st.checkbox('Show Anatomy Table'):
df = load_data()
st.markdown("## Anatomy Head to Toe Table with Body Organs Costly Conditions, Spending, CPT Codes and Frequency")
st.dataframe(df)
# CRUD operation buttons
col1, col2, col3, col4 = st.columns(4)
if col1.button('βž• Add'):
df = load_data()
df = add_data(df)
save_data(df)
if col2.button('πŸ”„ Update'):
df = load_data()
df = update_data(df)
save_data(df)
if col3.button('❌ Delete'):
df = load_data()
df = delete_data(df)
save_data(df)
if col4.button('πŸ’Ύ Save'):
df = load_data()
save_data(df)
st.success("Data saved to CSV!")