Proceeding from this post on histogramming, is there a way to override the histogram function to add the numbers instead of counting them?
For eg: ls=(0.3,1.4,1.6,2.3,3.2,4.7) in intervals of 2 gives [1.7,3.6,7.9]
Just a curiosity!
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
weightsargument tohistogram(official documentation for numpy.histogram). If I’ve understood you correctly, you can donumpy.histogram(ls,bins=(0,2,4,6),weights=ls), though that doesn’t give the result you stated (maybe you are using a different starting point for the bins?).