Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python pipe

# pip install pipe
from pipe import select, where, dedup


arr = [1,2,3,4,5,4,3,2,1,1,1]

res = list(arr
    | dedup					  # remove duplicates -> [1,2,3,4,5]
    | where(lambda e: e%2 == 0)  # filter for even numbers -> [2,4]
    | select(lambda e: e * 2)    # double all numbers -> [4,8]
)

print(res)  # -> [4,8]
Comment

PREVIOUS NEXT
Code Example
Python :: python split paragraph 
Python :: python count occurrences of an item in a list 
Python :: django execute 
Python :: numpy average 
Python :: pandas unique values to list 
Python :: how to use function in python 
Python :: iterative dfs python 
Python :: custom jupyter notebook 
Python :: numpy randint 
Python :: round off to two decimal places python 
Python :: build a pile of cubes python 
Python :: django prefetch_related vs select_related 
Python :: get_dummies 
Python :: declaring variables in python 
Python :: create columns in streamlit 
Python :: create qr code in python 
Python :: how to power in python 
Python :: reading json file 
Python :: django query multiple conditions 
Python :: python tkinter text get 
Python :: python cv2 imwrite 
Python :: convert 2d string array to float python 
Python :: string to tuple python 
Python :: how to display values on top of bar in barplot seaborn 
Python :: python convert hex number to decimal 
Python :: Exit code: ENOENT. spawn /usr/bin/python ENOENT 
Python :: Matplotlib rotated x tick labels 
Python :: break all loops 
Python :: pandas print tabulate no index 
Python :: compile python folder 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =