sspipe / sspipe Goto Github PK
View Code? Open in Web Editor NEWSimple Smart Pipe: python productivity-tool for rapid data manipulation
Home Page: https://sspipe.github.io/
License: MIT License
Simple Smart Pipe: python productivity-tool for rapid data manipulation
Home Page: https://sspipe.github.io/
License: MIT License
from sspipe import p, px
throws the error:
AttributeError: module 'pipe' has no attribute '__all__'
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
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
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.
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!
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!
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.
Can you please provide a few insights or comparisons around all these different pipe packages, especially with those specially designed for dataframes of pandas and spark?
from sspipe import p, px
from collections import OrderedDict
dict([(1,1),(4,2),(2,3)]).items() | p(sorted) | p(OrderedDict)
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
from sspipe import p, px
1 | p(print, "%s" %px)
2 | p(print, "{}".format(px)) not work either
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.