0

How could I approach to find 95th percentile of a column data? The question is: FInd the 95th percentile of earthquake magnitude in Japan using the magType of 'mb'.

I am able to filter Magtype 'mb', but how could I find the percentile?

import pandas as pd
import numpy as np

df = pd.read_csv('data/parsed.csv', usecols=['time', 'title', 'place',
            'magType', 'mag', 'alert','tsunami'])
Joe Ferndz
  • 8,417
  • 2
  • 13
  • 33
Lucas Batista
  • 143
  • 1
  • 5
  • Can you please share a sample records of the dataframe. df.head(20) – Joe Ferndz Nov 18 '20 at 01:56
  • see if this helps. https://stackoverflow.com/questions/50804120/how-do-i-get-the-percentile-for-a-row-in-a-pandas-dataframe – Joe Ferndz Nov 18 '20 at 01:59
  • https://stackoverflow.com/questions/39581893/pandas-find-percentile-stats-of-a-given-column – Joe Ferndz Nov 18 '20 at 02:02
  • Does this answer your question? [pandas: find percentile stats of a given column](https://stackoverflow.com/questions/39581893/pandas-find-percentile-stats-of-a-given-column) – Joe Ferndz Nov 18 '20 at 02:05

1 Answers1

0
df_place = df.groupby(["parsed_place"])
df_japan  = df_place.get_group("Japan")
df_japan.tail(2)
df_japan.quantile(0.95)
  • 1
    A good answer should include motivation for *why* the code provided works, not just *what* the code is. – Aplet123 May 18 '21 at 18:24