pyobsplot icon indicating copy to clipboard operation
pyobsplot copied to clipboard

Make shorthand definition possible

Open harrylojames opened this issue 2 years ago • 1 comments

Hi,

In line with having a syntax as close as possible to javascript it would nice to be able to use the shorthand syntax as seen here.

import pandas as pd
from pyobsplot import Plot

df = pd.DataFrame({'Date': {0: '1880-01-01', 1: '1880-02-01'}, 'Anomaly': {0: -0.3, 1: -0.21}})
Plot.lineY(df, {"x": "Date", "y": "Anomaly"}).plot()
AttributeError                            Traceback (most recent call last)
Cell In[15], line 5
      2 from pyobsplot import Plot
      4 df = pd.DataFrame({'Date': {0: '1880-01-01', 1: '1880-02-01'}, 'Anomaly': {0: -0.3, 1: -0.21}})
----> 5 Plot.lineY(df, {"x": "Date", "y": "Anomaly"}).plot()

AttributeError: 'dict' object has no attribute 'plot'

Not sure how feasible this is and not a dealbreaker for me but thought it was worth noting in case it wasn't on the radar.

Many thanks,

Harry

harrylojames avatar Jun 07 '23 16:06 harrylojames

I'm not sure I would be able to implement this given the way python Plot methods are automatically generated, but this is indeed a very valid suggestion.

I keep this open, thanks for the idea !

juba avatar Jun 08 '23 12:06 juba

This shortcut syntax should now be available in the development version (I have yet to add it to the documentation). It was much easier to implement than I thought.

Thanks again for the suggestion (and your patience).

I'm closing the issue for now but don't hesitate to reopen it if you encounter any problem.

juba avatar Sep 05 '24 08:09 juba