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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Mridul_Gupta
New Member

Python Histogram not displaying correct data

Hi there,

 

I have a small dataset with just 80 datapoints and I am trying to plot a histogram with a normal distrubution curve on top of it. When I run the following code in Jupyter notebook, I got a nice distribution of the values. (first photo)

 

However, when I run the same code in Power BI using the Python visual, I get a totally different histogram. I checked populating a table with the data I am using for the histogram which seems correct, so the data in Power BI is correct but for some reason the visual doesnt depict the same data.Does anyone know why this is happening?

 

Also, if I dont filter out the one negative value in the dataset, the histogram seems to be pretty close to the actual result but as soon as I filter the one record with the negative value, the histogram changes completely in values.From Jupyter NotebookFrom Jupyter NotebookWith the negative recordWith the negative recordwithout negative recordwithout negative record

 

Code:

import numpy as np
from scipy.stats import norm
import matplotlib.pyplot as plt
import pandas as pd
plt.hist(dataset.UCS_PoissonsRatio, bins = 33, density = False, edgecolor = "#FFFFFF")
mu, std = norm.fit(dataset.UCS_PoissonsRatio)
xmin, xmax = plt.xlim()
x = np.linspace(xmin, xmax, 100)
p = norm.pdf(x, mu, std)
plt.plot(x, p, 'k', linewidth=2)
plt.xlabel("Poisson Ratio")
plt.ylabel("Frequency")
plt.show()
1 REPLY 1
lbendlin
Super User
Super User

please provide the sample dataset.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.