Skip to main content
vestland's user avatar
vestland's user avatar
vestland's user avatar
vestland
  • Member for 10 years, 6 months
  • Last seen more than a month ago
  • Norway
Stats
60,228
reputation
4k
reached
0
answers
8
questions
Loading…
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))
This user doesn’t have any gold badges yet.
12
silver badges
13
bronze badges
0
Score
4
Posts
50
Posts %
0
Score
3
Posts
38
Posts %
0
Score
2
Posts
25
Posts %
0
Score
1
Posts
12
Posts %
0
Score
1
Posts
12
Posts %
0
Score
1
Posts
12
Posts %
Top posts