What is the difference between these to histogram code, why they are not giving same answers? Please tell

1 Like

→first case it setting default size of 10(your case numpy setting ~26), if bin size not given,

→ Second case you are allowing, your array to fit in the range(min and max) if the arrary is not sequencial.

More explanation here:

a : array_like
Input data. The histogram is computed over the flattened array.
bins : int or sequence of scalars or str, optional
If bins is an int, it defines the number of equal-width bins in the given range (10, by default). If bins is a sequence, it defines a monotonically increasing array of bin edges, including the rightmost edge, allowing for non-uniform bin widths.