Thursday, July 12, 2018

Add multiple columns to Pandas dataframe by applying a function that returns multiple values

df[['sum', 'difference']] = df.apply(
    lambda row: pd.Series(myfunc(row['a'], row['b'])), axis=1)
# The pd.Series is the key!

Tuesday, May 8, 2018

Python read files line by line

fo = open('inputFileName', 'r')
lines = fo.readlines()
for ln in lines:
    print(ln)

Tuesday, May 1, 2018

To remove parenthesis and all the stuff inside:

AAV (South Africa) Volkswagen
AHT (South Africa) Toyota
AFA (South Africa) Ford
CL9 (Tunisia) Wallyscar

sed -e 's/([^()]*)//g'


AAV     Volkswagen
AHT     Toyota
AFA     Ford

CL9     Wallyscar

my-alpine and docker-compose.yml

 ``` version: '1' services:     man:       build: .       image: my-alpine:latest   ```  Dockerfile: ``` FROM alpine:latest ENV PYTH...