Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import matplotlib.pyplot as plt
- # Replace 'B5 segmentSummary (1).csv' with the actual CSV file path
- file_path = 'B5 segmentSummary (1).csv'
- # Define the range of column positions you want to analyze (columns 6 through 10)
- start_column_position = 6 # Corresponds to column 6
- end_column_position = 9 # Corresponds to column 10
- # Read the CSV file into a Pandas DataFrame
- df = pd.read_csv(file_path)
- # Select columns 6 through 10 for analysis
- selected_columns = df.iloc[:, start_column_position:end_column_position + 1]
- # Calculate summary statistics for the selected columns
- summary_statistics = selected_columns.describe()
- # Transpose the summary statistics for plotting
- summary_statistics = summary_statistics.T
- # Extract the statistics you want to plot
- statistics_to_plot = ['mean', 'std', 'min', '25%', '50%', '75%', 'max']
- # Create a grouped bar plot for the selected statistics
- plt.figure(figsize=(12, 6))
- x = range(len(summary_statistics.index))
- bar_width = 0.15
- for i, statistic in enumerate(statistics_to_plot):
- plt.bar(
- [pos + i * bar_width for pos in x],
- summary_statistics[statistic],
- width=bar_width,
- label=statistic
- )
- plt.xlabel('Columns')
- plt.ylabel('Values')
- plt.title('Summary Statistics for Selected Columns')
- plt.xticks([pos + 3 * bar_width for pos in x], summary_statistics.index, rotation=45)
- plt.legend()
- plt.tight_layout()
- # Show the plot
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement