vestland's user avatar
vestland's user avatar
vestland's user avatar
vestland
  • Member for 1 year
  • Last seen more than 1 year ago
  • Norway
About

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))
Badges
This user doesn’t have any gold badges yet.
This user doesn’t have any silver badges yet.
1
bronze badge
Posts

This user hasn’t posted yet.