Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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!
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!