Questions tagged [bins]

235 questions
36
votes
2 answers

Matplotlib histogram with collection bin for high values

I have an array with values, and I want to create a histogram of it. I am mainly interested in the low end numbers, and want to collect every number above 300 in one bin. This bin should have the same width as all other (equally wide) bins. How can…
physicalattraction
  • 6,485
  • 10
  • 63
  • 122
32
votes
4 answers

Categorize numeric variable into group/ bins/ breaks

I am trying to categorize a numeric variable (age) into groups defined by intervals so it will not be continuous. I have this code: data$agegrp(data$age >= 40 & data$age <= 49) <- 3 data$agegrp(data$age >= 30 & data$age <= 39) <-…
leian
  • 443
  • 2
  • 5
  • 5
16
votes
3 answers

With `pandas.cut()`, how do I get integer bins and avoid getting a negative lowest bound?

My dataframe has zero as the lowest value. I am trying to use the precision and include_lowest parameters of pandas.cut(), but I can't get the intervals consist of integers rather than floats with one decimal. I can also not get the left most…
joelostblom
  • 43,590
  • 17
  • 150
  • 159
12
votes
2 answers

Python Pandas Create New Bin/Bucket Variable with pd.qcut

How do you create a new Bin/Bucket Variable using pd.qut in python? This might seem elementary to experienced users but I was not super clear on this and it was surprisingly unintuitive to search for on stack overflow/google. Some thorough searching…
sfortney
  • 2,075
  • 6
  • 23
  • 43
12
votes
5 answers

how to generate bins for histogram using apache math 3.0 in java?

I have been looking for away to generate bins for specific dataset (by specifying lower band, upper band and number of bins required) using apache common math 3.0. I have looked at Frequency…
Sami
  • 7,797
  • 18
  • 45
  • 69
10
votes
3 answers

Increasing space between bins in seaborn distplot

So I have this, probably, simple question. I created a histogram from data out of an excel file with seaborn. Forbetter visualization, I would like to have some space between the bars/bins. Is that possible? My code looks as followed import pandas…
Jul
  • 173
  • 3
  • 3
  • 7
10
votes
1 answer

How to organize values in a numpy array into bins that contain a certain range of values?

I am trying to sort values in an numpy array so that I can store all of the values that are in a certain range (That could probably be phrased better). Anyway ill give an example of what I am trying to do. I have an array called bins that looks like…
sTr8_Struggin
  • 665
  • 2
  • 11
  • 27
7
votes
1 answer

Understanding the glibc malloc binning implementation

lately i've been studying the internals of the glibc malloc implementation. However, there is one thing i can't seem to understand regarding bin indexing. So within the malloc_state structure we have the following declarations, lightly formatted for…
7
votes
5 answers

Normalizing histogram bins in gnuplot

I'm trying to plot a histogram whose bins are normalized by the number of elements in the bin. I'm using the following binwidth=5 bin(x,width)=width*floor(x/width) + binwidth/2.0 plot 'file' using (bin($2, binwidth)):($4) smooth freq with…
shivknight
  • 96
  • 1
  • 1
  • 5
7
votes
1 answer

Unable to align bins in a histogram of datetime objects using the hist() function

So I am trying to plot a histogram of some datetime objects, but i can never get the bins to line up with the bars. My code is below: I start by importing my stuff and declaring the start, end and a one day object: import datetime import…
emily
  • 73
  • 1
  • 3
6
votes
2 answers

Pandas: Bin dates into 30 minute intervals and calculate averages

I have a Pandas dataframe with two columns which are speed and time. speed date 54.72 1:33:56 49.37 1:33:59 37.03 1:34:03 24.02 7:39:58 28.02 7:40:01 24.04 7:40:04 24.02 7:40:07 25.35 7:40:10 26.69 7:40:13 32.04 7:40:16 28.02 …
manosbar
  • 318
  • 2
  • 3
  • 15
5
votes
1 answer

MATLAB: combining and normalizing histograms with different sample sizes

I have four sets of data, the distribution of which I would like to represent in MATLAB in one figure. Current code…
user3470496
  • 141
  • 7
  • 33
5
votes
3 answers

Plotting a choropleth map (with geopandas) using a user_defined classification scheme

I'm kind of new to python, so I'm hoping that the answer to my question is relatively straight forward. I'm trying to make a choropleth map using geopandas. However, since I'm making multiple maps that need to be compared to each other, it is…
Chiara
  • 53
  • 1
  • 3
5
votes
3 answers

Python: Assigning # values in a list to bins, by rounding up

I want a function that can take a series and a set of bins, and basically round up to the nearest bin. For example: my_series = [ 1, 1.5, 2, 2.3, 2.6, 3] def my_function(my_series, bins): ... my_function(my_series, bins=[1,2,3]) >…
Afflatus
  • 2,302
  • 5
  • 25
  • 40
4
votes
1 answer

Am I using histc wrong, or is this MATLAB's fault?

Ok, here's some code in MATLAB: data = [1 1.5 2 3 4 4.5 5 6 7 7 7 0 0 0]; histc(data, [1:1:5]) histc(data, [1:1:5, inf]) histc(data, [-inf, 1:1:5]) which outputs the following: ans = 2 1 1 2 1 ans = 2 1 1 2 5 …
Pyrolistical
  • 27,624
  • 21
  • 81
  • 106
1
2 3
15 16