vestland

121
reputation
5

No mystery. Lots of air. And some resources:

Small snippets of great use:

# pandas dataframes in and out

os.listdir(os.getcwd()) os.getcwd() os.chdir('C:/repos/py_research/import')

df = pd.read_clipboard(sep='\s+') df = df.astype(str) df = df.apply(lambda x: x.str.replace(',','.')) df = df.astype(float)

df = pd.read_csv(r'C:\dbs.csv',sep = ",", header = None) df.to_csv(r'C:\dbs.csv', sep=',', float_format='%.2f', decimal = '.', index=False)

replaze zeros

df = df.replace({'0':np.nan, 0:np.nan})

IPython magic

%prun #Show how much time your program spent in each function

!ls *.csv # execute shell command inside notebook

A few SO posts I always come back to:

Some valuable resources:

Installations:

conda config --set ssl_verify False # https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html

Datasets: plotly

Windows Commands

https://www.howtogeek.com/194041/how-to-open-the-command-prompt-as-administrator-in-windows-8.1/

IDEs

#VSCode
https://code.visualstudio.com/docs/python/environments

How to map arguments in functions:

def SetColor(x):
        if(x == 'A'):
            return "1"
        elif(x == 'B'):
            return "2"
        elif(x == 'C'):
            return "3"

lst = ['A', 'B', 'C']

list(map(SetColor, lst))