Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
TK093552
New Member

notebook

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.

 
import pandas as pd
import matplotlib as plt

# Load data into pandas DataFrame from "/lakehouse/default/Files/data.csv"
df = pd.read_csv("/lakehouse/default/Files/data.csv")
x = df['Duration']
y = df['Pulse']
 
plt.bar(x, y, label="Blue Bar", color='b')
plt.show()
 
In this program, I'm unable to extract the data for x and y axis.

 

 

1 REPLY 1
saud968
Super User
Super User

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!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors