Spaces:
Runtime error
Runtime error
File size: 1,859 Bytes
e7ba4db |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
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() |