home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 461127850

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
461127850 MDU6SXNzdWU0NjExMjc4NTA= 3050 Pipe Operator? 5635139 closed 0     1 2019-06-26T18:51:31Z 2019-07-05T07:12:07Z 2019-07-05T07:12:07Z MEMBER      

I realize this is a topic primed for bike-shedding, so I've held off suggesting, but here goes...

Is there any interest in a pipe operator to make xarray syntax easier? Our internal code has much code like:

```python

delinq_c = ( base_ds['delinq_comp_array'] # lots of pipe lines! .pipe(lambda x: x - base_ds['delinq_comp_array'].mean('fsym_id')) .pipe(lambda x: x / delinq_diff) .pipe(lambda x: x * 2) )

```

...with lots of new lines starting with .pipe. The fluent code is great for sequences of logic, but the requirement to have .pipe on each line adds verbosity.

The addition of a pipe operator would allow for:

```python

delinq_c = ( base_ds['delinq_comp_array'] >> lambda x: x - base_ds['delinq_comp_array'].mean('fsym_id') >> lambda x: x / delinq_diff >> lambda x: x * 2 )

```

This requires (ab)using an existing python operator, such as >> (bitshift operator) or | (or operator). Airflow uses >>, Beam (and bash) use |. While xarray doesn't allow either to be used, other libraries might incorrectly assume their presence implies they work consistently with those definitions.

Python has explicitly not added this, nor reduced the character count of lambda x:, so this would be somewhat a dissent from their standards, and introduce potential confusion to completely new xarray users.

I remember some discussions at pandas on similar topics. I can't find them all, but here's an issue re adding the X term https://github.com/pandas-dev/pandas/issues/13133

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3050/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 0.628ms · About: xarray-datasette