Cara menggunakan python list quantile

Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas dataframe.quantile() function return values at the given quantile over requested axis, a numpy.percentile. Note : In each of any set of values of a variate which divide a frequency distribution into equal groups, each containing the same fraction of the total population.

Syntax: DataFrame.quantile(q=0.5, axis=0, numeric_only=True, interpolation=’linear’) 

Parameters : q : float or array-like, default 0.5 (50% quantile). 0 <= q <= 1, the quantile(s) to compute 

axis : [{0, 1, ‘index’, ‘columns’} (default 0)] 0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise 

numeric_only : If False, the quantile of datetime and timedelta data will be computed as well 

interpolation : {‘linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’} 

Returns : quantiles : Series or DataFrame -> If q is an array, a DataFrame will be returned where the index is q, the columns are the columns of self, and the values are the quantiles. -> If q is a float, a Series will be returned where the index is the columns of self and the values are the quantiles.

Example #1: Use quantile() function to find the value of “.2” quantile 

Python3




# importing pandas as pd

import pandas as pd

 

# Creating the dataframe

df= pd.DataFrame({"A":[1,5,import1,import3,import5import6

import7import8import1,import5,import3,import1,import3import6

import7# Creating the dataframe0import5,import5,# Creating the dataframe5,import1,import3import6

import7df2import3,import1,df7,df9,# Creating the dataframe5=2

 

=3

df

 

Let’s use the dataframe.quantile() function to find the quantile of ‘.2’ for each column in the dataframe 

Python3




=5

=6import5=8= pd.DataFrame({"A":[0pd.DataFrame({"A":[1

Output :

 

 

Example #2: Use quantile() function to find the (.1, .25, .5, .75) quantiles along the index axis. 

Python3




# importing pandas as pd

import pandas as pd

 

# Creating the dataframe

df= pd.DataFrame({"A":[1,5,import1,import3,import5import6

import7import8import1,import5,import3,import1,import3import6

import7# Creating the dataframe0import5,import5,# Creating the dataframe5,import1,import3import6

import7df2import3,import1,df7,df9,# Creating the dataframe5=2

 

import15

import16

import171import19import20import195import19import24import25= pd.DataFrame({"A":[0pd.DataFrame({"A":[1

Postingan terbaru

LIHAT SEMUA