Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
I'm trying to extract data from csv file to use bar chat using python. I have loaded the data from the csv file to pandas data frame. However, to make a bar chart I'm unable to use the data from the csv file. e.g. the csv file has 4 columns. I'm trying to extract two of the columns to make a bar chart.
Try this
import pandas as pd
import matplotlib.pyplot as plt
# Load data into pandas DataFrame from "/lakehouse/default/Files/data.csv"
df = pd.read_csv("/lakehouse/default/Files/data.csv")
# Extract the columns you want to use for the bar chart
x = df['Duration']
y = df['Pulse']
# Create the bar chart
plt.bar(x, y, label="Blue Bar", color='b')
# Add labels and title for better readability
plt.xlabel('Duration')
plt.ylabel('Pulse')
plt.title('Duration vs Pulse')
plt.legend()
# Display the bar chart
plt.show()
Here are a few things to check:
Column Names: Ensure that the column names in your CSV file match exactly with 'Duration' and 'Pulse'. Column names are case-sensitive.
Data Types: Verify that the data in these columns are suitable for plotting. For example, 'Duration' should be numerical or categorical, and 'Pulse' should be numerical.
Matplotlib Import: Make sure you import pyplot from matplotlib correctly.
Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!