Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 
avatar of vestland

vestland

vestland has asked 80 questions and find answers to 201 problems.

Stats

6.4k
EtPoint
2.1k
Vote count
80
questions
201
answers

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:

  • SO link magic

  • How to make good reproducible pandas examples

  • Python Pandas Counting the Occurrences of a Specific value

  • How to get all images posted by me?

Some valuable resources:

  • Plotly: Python figure reference

  • Plotly: x-axis tickformat, dates

  • Plotly: Scatter plots with python

  • Plotly: Gantt charts with python

  • IPython: 28 tips

  • Google Chrome inspect elements

Installations:

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

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))