python histogram with arbitrary sized bins

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

data = pd.read_csv(‘data.csv’)

factors, edges = pd.qcut(data.iloc[:,3],np.arange(0,1,0.25),retbins=True)   “”” or replace np.arange(0,1,0,25) with any array of quantiles eg [0,.1,.25,.7,.99]”””

plt.hist(data.iloc[:,3],edges)

plt.show()

This entry was posted in python and tagged , , . Bookmark the permalink.

Leave a comment