DataFrame.quantile

DataFrame.quantile(q: int | float | List[int] | List[float] = 0.5, numeric_only: bool | None = True) DataFrame[source]

Used to calculate quantile for a given DataFrame.

Parameters

q:

float or array like, default 0.5 Value between 0 <= q <= 1, the quantile(s) to compute.

numeric_only: {True, False, None} Default is True

Which datatype to be returned - True: Returns all values as float64, NaN/NaT values are removed - None: Returns all values as the same dtype where possible, NaN/NaT are removed - False: Returns all values as the same dtype where possible, NaN/NaT are preserved

Returns

pandas.DataFrame

quantile value for each column

See Also

:pandas_api_docs:`pandas.DataFrame.quantile`

Examples

>>> from tests import OPENSEARCH_TEST_CLIENT
>>> oml_df = oml.DataFrame(OPENSEARCH_TEST_CLIENT, 'flights')
>>> oml_flights = oml_df.filter(["AvgTicketPrice", "FlightDelayMin", "dayOfWeek", "timestamp"])
>>> oml_flights.quantile() 
AvgTicketPrice    640.387285
FlightDelayMin      0.000000
dayOfWeek           3.000000
Name: 0.5, dtype: float64
>>> oml_flights.quantile([.2, .5, .75]) 
      AvgTicketPrice  FlightDelayMin  dayOfWeek
0.20      361.040768             0.0        1.0
0.50      640.387285             0.0        3.0
0.75      842.213490            15.0        4.0
>>> oml_flights.quantile([.2, .5, .75], numeric_only=False) 
      AvgTicketPrice  FlightDelayMin  dayOfWeek                     timestamp
0.20      361.040768             0.0        1.0 2018-01-09 04:43:55.296587520
0.50      640.387285             0.0        3.0 2018-01-21 23:51:57.637076736
0.75      842.213490            15.0        4.0 2018-02-01 04:46:16.658119680