Is there a way to create a bar plot from continuous data binned into predefined intervals? For example,
In[1]: df
Out[1]:
0 0.729630
1 0.699620
2
You may consider using matplotlib to plot the histogram. Unlike pandas' hist
function, matplotlib.pyplot.hist
accepts an array as input for the bins.
import numpy as np; np.random.seed(0)
import matplotlib.pyplot as plt
import pandas as pd
x = np.random.rand(120)
df = pd.DataFrame({"x":x})
bins= [0,0.35,0.7,1]
plt.hist(df.values, bins=bins, edgecolor="k")
plt.xticks(bins)
plt.show()