Questions tagged [quartile]

Quartiles are the values that divide a list of numbers into quarters.

Quartiles are the values that divide a list of numbers into quarters.

Further reference: https://www.mathsisfun.com/data/quartiles.html

115 questions
2
votes
1 answer

Calculate quantiles of vector producing unexpected results

I was asked to calculate BY HAND the IQR of this data -1,400 -1,000 -0,600 0,400 1,000 1,700 2,300 2,600 3,300 3,700 4,400 4,600 7,000 7,500 7,700 13,500 18,500 The results are MEDIAN 3.300 1 QUARTILE 1 3 QUARTILE…
2
votes
1 answer

How to label quartiles in matplotlib boxplots?

I have a list of values which I want to plot the distribution for. I'm using a box-plot but it would be nice to add some dotted lines going from the boxplot quartiles to the axis. Also I want just the quartile values displayed on the x ticks. Here's…
RobotBarry
  • 73
  • 2
  • 11
2
votes
2 answers

Linear interpolation in numpy quantile()

Consider the following code: >>> import numpy as np >>> l = [21,22,24,24,26,97] >>> np.quantile(l, 0.25) 22.5 The documentation says: linear: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j. Could…
Maxim Blumental
  • 763
  • 5
  • 26
2
votes
1 answer

How to replace outliers with values inside the IQR for multiple variables and individuals

I have a dataset similar to iris, and need to write a function that deals with outliers in the following way: for each species setosa, versicolor, and virginica, within each variable iris$Sepal.Length, iris$Sepal.Width, iris$Petal.Length, and…
Ryan
  • 1,048
  • 7
  • 14
2
votes
5 answers

Using Numpy, how 25 percentile is calculate for number 1 to10?

from numpy import percentile import numpy as np data=np.array([1,2,3,4,5,6,7,8,9,10]) # calculate quartiles quartile_1 = percentile(data, 25) quartile_3 =percentile(data, 75) # calculate min/max print(quartile_1) # show 3.25 print(quartile_3) #…
2
votes
1 answer

Optimising quartiling of columns of panda dataframe?

I have multiple columns in a data frame that have numerical data. I want to quartile each column, changing each value to either q1, q2, q3 or q4. I currently loop through each column and change them using the pandas qcut function: for column_name…
Dave
  • 454
  • 1
  • 7
  • 17
2
votes
1 answer

Calculate First Quartile of a dataset using data.frame() where row numbers have been removed in R

mylist2<-list(as.numeric(c(1:20)),(c(1:20)**2),sqrt(c(1:20))) iData<-data.frame(do.call(cbind,mylist2)) print(iData,row.names=FALSE) quantile(iData$X1,iData$X2,iData$X3,c(0.25,0.25,0.25)) I want to display these column combined vectors its first…
tytds
  • 61
  • 1
  • 2
2
votes
1 answer

How can I efficiently get [many] quartiles?

I need to encode numerical values by ranges: low: 0, medium: 1, high: 2 , very high: 3. I'm doing it for quartiles. I have the following code: import pandas as pd import numpy as np def fun(df): table = df.copy() # pandas dataframe N =…
1
vote
1 answer

How to find top quartile & bottom quartile in R?

Using the mtcars dataset, find car(s) within the top quartile in MPG, bottom quartile in weight, and 5 gears. I know the answer it just codes not fitting in. data.frame(mtcars) mtcars %>% filter(gear>=5) mtcars[mtcars$wt == min(mtcars$wt), "wt",…
shubha
  • 13
  • 2
1
vote
0 answers

How to prevent same value existing indifferent quartiles using ntile() in redshift?

I am attempting to identify what quartile values in a particular column in my temp table fall into. Using the ntile function to sort these values into their respective quartiles, the maximum value of one quartile is the same as the minimum value of…
gabby
  • 11
  • 3
1
vote
2 answers

Calculate Exact Values Of Lower and Upper Quartiles

I have been looking all around internet and it seems like there is no answer that match my case. I am struggling with calculating the exact Lower and Upper Quartile in SQL Server. I am aware that SQL Server has a built in function that facilitates…
LordSilvermort
  • 237
  • 2
  • 8
1
vote
1 answer

Dataframe - quartile from rows

df: a | b | c | d | q3 - q1 from (a,b,c,d) 1 | 2 | 3 | 4 | result 5 | 6 | 2 | 7 | result Can someone help me with this result? (q -> quartile)
user17031311
1
vote
2 answers

Why are the quartiles in seaborn boxplot different from ploty? How can I put them to show me the same result?

Seaborn Importing libraries and load data import pandas as pd import seaborn as sns from matplotlib import pyplot as plt sns.set_theme(style="whitegrid", palette="muted") # Set2, muted, pastel, colorblind # Load the data import plotly.express…
Elizio Era
  • 11
  • 1
1
vote
2 answers

How do you print the values in a list from a certain percentile and up (ex: list no. from 95th-100rd percentile) without using multiple np statements?

My current code is this: import numpy as np list1 = [] n = int(input("Enter number of elements for list 1: ")) for i in range(0, n): ele = float(input("Enter a number: ")) list1.append(ele) list2 = [] n =…
Preston B.
  • 23
  • 5
1
vote
1 answer

How to find the quartiles in the linked list with only one iteration

I have a singly linked list of integers. The node is defined as class Node { public: int value; Node *next = NULL; }; I need to find the q1,q2, and q3( first, second and third quartile) respectively. It is…
Sreeragh M
  • 80
  • 1
  • 8