Can someone help me sort a group of floats into bins no larger than a value of 10? I have two problems in that the program is reading a set of files and creating individual arrays for each value. Second I'm unsure as to what is going on with the numpy binning.
for filename in glob.iglob('*.html'):
with open(filename) as f:
soup = BeautifulSoup(f)
results = []
weight = soup.find('b', text='Shipping Weight:').next_sibling
title = soup.find("span", id="btAsinTitle")
results = weight
import re
import scipy
import numpy as np
result_str = re.findall(r"[-+]?\d*\.\d+|\d+", results)
result = float(result_str[0])
#print result
array_weight = [result]
print array_weight
x = np.array(array_weight)
bins = np.array([10.0])
inds = np.digitize(x, bins)
print inds
restuff to help you with sorting/binning floats. Start with your array of floats and go from there, otherwise I am a bit lost.