Why pandas insert spaces into my histogram?

Sample data can be found here in CSV format.

Given the following code:

figure()
grp.vis.plot(kind='hist', alpha=.5, normed=True)
show()

I get the following picture:

enter image description here

Why does pandas insert spaces in the image? Values ​​range from 0 to 7, and they are all presented, so I see no reason why this should happen.

Thank you very much in advance!

+4
source share
2 answers

Since the parameter binswith the default value 10is in hist:

grp.vis.plot(kind='hist', alpha=.5, bins=7, normed=True)

graph

If omitted rwidth:

grp.vis.plot(kind='hist', alpha=.5, bins=7)

graph1

Documents :

Bunkers : integer or array_like, optional

, + 1 , numpy.histogram() numpy version >= 1.3.

, .

10

rwidth: None,

. None, .

, histtype "step" "stepfilled".

: None

+4

, , , physt (. https://github.com/janpipek/physt). , ( "" ) "" .

import pandas as pd
import physt

df = pd.read_csv("visanal_so.csv")
ax = physt.h1(df.vis, "integer").plot(density=True, alpha=0.5)
ax.set_ylabel("Frequency");

What are you getting

P.S. , , , @jezrael. pandas binning , .

+1

All Articles