redflag icon indicating copy to clipboard operation
redflag copied to clipboard

Accessor for `pd.DataFrame`

Open kwinkunks opened this issue 2 years ago • 1 comments

Could be interesting to implement detectors etc as methods on DataFrames, eg

df = pd.read_csv('my_data.csv')

df.rf.find_outliers()

How-to: https://pandas.pydata.org/docs/development/extending.html

Could do the same for xarrays I guess, but DataFrames are key.

kwinkunks avatar Jul 29 '23 08:07 kwinkunks

API like:

df.redflag.cool_method(X=None, y=None, **kwargs)

E.g.

features = ['GR', 'RHOB', 'PE']  # Columns in df.
df.redflag.cool_method(X=features, y='Lithology')  # y can also be a list.

Then...

  • If X and y are None, treat the whole df as X
  • If only X is None, use y and treat the remaining columns as X
  • If only y is None, use X and ignore y

kwinkunks avatar Sep 27 '23 19:09 kwinkunks