Code Monkey home page Code Monkey logo

sspipe's Issues

Expression used warning

When using sspipe, pyright gives a warning of "Expression value is unused" if not assignment is given for sspipe statements. Please see a screenshot below.

image

Is there a nice way to let lsp not complain about this?

Stuck when zipping

I'm trying to zip/unzip an array, but the console always hangs up. Is this a bug, or am I doing something wrong?

from sspipe import p, px

[[1, 2, 3], [4, 5, 6]] | p(zip, px)       # zip, console/notebook gets stuck
[[1, 2], [3, 4], [5, 6]] | p(zip, *px)    # unzip, console/notebook gets stuck

Questions: unpipe() and general compatibility

Hey man, first let me say that sspipe is my favorite python package, it is a game changer in my opinion.
I believe the combination of functional programming and pipe operator is the best paradigm and Python was really deficient in that regard.
Thank you very much to provide this package and I hope it gets the all attention it deserves!

I have 2 questions:

(1) What are the uses of unpipe? Are there some documentation and examples using it?

(2) Can sspipe be used robustly throughout python ecosystem or there are some cases/environments that it should be avoided to prevent some critical incompatibility?

Best regards

A composition framework that involves sspipe

Hi,
I have built such python framework that allows for composition of functions . sspipe really enables me to take the next level.
I also did a fork with name and contextvars feature (needed). Let me know if you would include it (it is backward-comptabile, but won't add value without the entire framework). Could do a PR.

And also wanted to hear WDYT and if you would recommend it , that would be appreciated.

https://github.com/eyalk11/composition

Thanks.

Question: Applying multiple operations in one call to p

Generally - a great library! The simplifications for usability on Julien's Pipe are important.

The question here is: I generally define a simple function

def lmap(x): return list(map(x))

This is useful since python3 map,filter, etc return a generator and it is chatty to have list(blah) everywhere to compensate. But with this sspipe library it does not work: needs to be

| p(map) | p(list)

i.e. the list and map can not be combined into a single invocation of p. We can extrapolate this to be a hassle. You're a bright guy - can you come up with a solution/workaround to be able to combine multiple operations in one call to p ? Thx!

pipe iterator into next function

sspipe hangs up when the output is an iterator and the next function iterates over the prior output.

reduce(lambda x, y: x + y, [1, 2, 3, 4]) yields 10 but [1, 2, 3, 4] | reduce(lambda x, y: x + y, px) hangs up

[x + 1 for x in [1, 2, 3, 4]] yields [2, 3, 4, 6] but [1, 2, 3, 4] | [x + 1 for x in px] hangs up

Would love a way to pass iterators!

`TypeError` on conditional

Is there a way to make the following working Pandas code more concise?

value = data | px[px.SOME_COLUMN == 10] # data: DataFrame
if not value.empty:
    print(value.ANOTHER_COLUMN.astype(str).values[0])

I tried this:

data | px[px.SOME_COLUMN == 40] | (px if not px.empty else exit()) | px.ANOTHER_COLUMN.astype(str).values[0] | p(print)

but I got a TypeError:

Traceback (most recent call last):
  File "/test_pandas.py", line 25, in <module>
    data | px[px.SOME_COLUMN == 40] | (px if not px.empty else exit()) | px.ANOTHER_COLUMN.astype(str).values[0] | p(print)
TypeError: 'Pipe' object cannot be interpreted as an integer

Essentially, I'm trying not to print if the DataFrame is empty.

TypeError: 'Pipe' object cannot be interpreted as an integer

Hi,

My pipelines built with sspipe often fail due to TypeError on one of the transformations. Even though each step returns a DataFrame object I still get this failure.

Sample Code:


import pandas as pd
from sspipe import px
from urllib.request import urlretrieve

# Get Data to work with
url = 'http://files.zillowstatic.com/research/public/Neighborhood/Neighborhood_MedianRentalPrice_AllHomes.csv'
local_path = './Neighborhood_MedianRentalPrice_AllHomes.csv'
urlretrieve(url, local_path)

zillow = pd.read_csv(local_path)

# This Works
zillow_regions =  zillow \
    .loc[zillow.State.isin(['CA', 'NY', 'WA', 'DC']), ['RegionName', 'City', 'State']] \
    .sort_values(['City', 'RegionName']) \
    .drop_duplicates()

# This Does Not Work
zillow_regions = (
    zillow
    | px.loc[px.State.isin(['CA', 'NY', 'WA', 'DC']), ['RegionName', 'City', 'State']]
    | px.sort_values(['City', 'RegionName'])
    | px.drop_duplicates()
)
zillow_regions.head()

Error Message when using sspipe:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: 'Pipe' object cannot be interpreted as an integer
Exception ignored in: 'pandas._libs.tslibs.util.is_period_object'
TypeError: 'Pipe' object cannot be interpreted as an integer
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: 'Pipe' object cannot be interpreted as an integer
Exception ignored in: 'pandas._libs.lib.is_interval'
TypeError: 'Pipe' object cannot be interpreted as an integer
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: 'Pipe' object cannot be interpreted as an integer
Exception ignored in: 'pandas._libs.tslibs.util.is_offset_object'
TypeError: 'Pipe' object cannot be interpreted as an integer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.