import pandas as pd import streamlit as st # Load the XLSX file using pandas data = pd.read_excel('your_file.xlsx') # Perform EDA on the data # ... # Function to create the top ten ordered distribution def create_top_ten_distribution(data, column): # Count the unique values and blanks in the specified column value_counts = data[column].value_counts(dropna=False) # Create a DataFrame with the top ten values and their counts top_ten_df = pd.DataFrame({'Value': value_counts.index, 'Count': value_counts.values}) top_ten_df['Rank'] = range(1, len(top_ten_df) + 1) return top_ten_df.head(10) # Function to display the filtered dataframe based on rank def display_filtered_dataframe(data, column, rank): # Get the value corresponding to the specified rank value = top_ten_df[top_ten_df['Rank'] == rank]['Value'].values[0] # Filter the dataframe based on the value filtered_df = data[data[column] == value] return filtered_df # Streamlit app def main(): st.title('Top Ten Distribution and Filtered Dataframe') # Specify the column for creating the top ten distribution column = 'your_column_name' # Create the top ten ordered distribution top_ten_df = create_top_ten_distribution(data, column) # Display the top ten distribution as a markdown table st.markdown('### Top Ten Distribution') st.markdown(top_ten_df.to_markdown(index=False)) # Get the user input for the rank rank = st.number_input('Enter the rank to filter the dataframe', min_value=1, max_value=10, value=1, step=1) # Display the filtered dataframe based on the rank filtered_df = display_filtered_dataframe(data, column, rank) st.markdown(f'### Filtered Dataframe (Rank: {rank})') st.dataframe(filtered_df) if __name__ == '__main__': main()