Category : pandas

I have the following code: import streamlit as st import pandas as pd #define data d = {‘id’: [‘a’, ‘b’, ‘c’], ‘data’: [3, 4,6]} df = pd.DataFrame(data=d) #create sidebar input with st.sidebar.form("my_form"): a = st.slider(‘sidebar for testing’, 5, 10, 9) calculate = st.form_submit_button(‘Calculate’) if calculate: df[‘result’] = df[‘data’] + a st.write(df) #no issues up to ..

Read more

I am trying to remove the "edge color" from a stacked area chart in python, as the plots tend to get "overlaid" by the "last" column: import pandas as pd, numpy as np df = pd.DataFrame(np.random.randint(0, 10000, size=(10000, 4)), columns=list(‘ABCD’)) import matplotlib.pyplot as plt, seaborn as sns def myplot(df): fig, ax = plt.subplots(figsize=(4, 4)) df.plot.area(ax=ax) ..

Read more

i want the sum of all subcounts printed in a pivot table. table = pd.pivot_table(df, index = [‘value1’, ‘value2’], values = [‘value3’], aggfunc = [np.count_nonzero]) Output of print(table.loc[value1example]): count_nonzero value3 value2 value2examplea 766 value2exampleb 265 value2examplec 19 I want the following: count_nonzero value3 value2 950 value2examplea 766 value2exampleb 265 value2examplec 19 Do you have an ..

Read more