Skip to content

Instantly share code, notes, and snippets.

@rolroralra
Last active January 13, 2021 12:17
Show Gist options
  • Save rolroralra/bce7222c1feb20b66a75487ea45f0b70 to your computer and use it in GitHub Desktop.
Save rolroralra/bce7222c1feb20b66a75487ea45f0b70 to your computer and use it in GitHub Desktop.
Anaconda

5 ways to apply an IF condition in pandas DataFrame

https://datatofish.com/if-condition-in-pandas-dataframe/


Install Anaconda

https://docs.anaconda.com/anaconda/install/

  • Anaconda Navigator
  • Jupyter Notebook
  • Spyder

How to Set Daemon for Jupyter Notebook

https://gist.github.com/rolroralra/17a2a58bb1fe9dec594d4c6a0c707a7a#how-to-setup-jupyter-notebook-server-as-a-daemon-service

Details

$ jupyter notebook --generate-config

$ vi ~/.jupyter/jupyter_notebook_config.py
c = get_config()
c.NotebookApp.allow_origin = '*'
c.NotebookApp.allow_remote_access = True
## The IP address the notebook server will listen on.
c.NotebookApp.ip = 'localhost'
## The port the notebook server will listen on.
#c.NotebookApp.port = 8888
c.NotebookApp.notebook_dir = '/home/rolroralra/Workspace/jupyter_notebook'
c.NotebookApp.open_browser = False
c.NotebookApp.password = 'sha1:f24baff49ac5:863dd2ae747212ede58125302d227f0ca7b12bb3'
c.MultiKernelManager.default_kernel_name = 'venvpy3'
EOF

$ python
from notebook.auth import passwd 
passwd()
Enter password: 
Verify password: 
'sha1:f24baff49ac5:863dd2ae747212ede58125302d227f0ca7b12bb3'

$ sudo vi /etc/systemd/system/jupyter.service
[Unit]
Description=Jupyter Notebook Server

[Service]
Type=simple
PIDFile=/run/jupyter.pid
User=rolroralra
Group=rolroralra
#EnvironmentFile=/home/rolroralra/.jupyter/env
# Jupyter Notebook: change PATHs as needed for your system
ExecStart=/home/rolroralra/.local/bin/jupyter-notebook --config=/home/rolroralra/.jupyter/jupyter_notebook_config.py
# In case you want to use jupyter-lab 
# ExecStart=/home/rolroralra/.local/bin/jupyter-lab --config=/home/rolroralra/.jupyter/jupyter_notebook_config.py
WorkingDirectory=/home/rolroralra/Workspace/jupyter_notebook
Restart=always
RestartSec=10
#KillMode=mixed

[Install]
WantedBy=multi-user.target

# from venv install kernel     
$ pip install ipykernel

# install custom venv kernel 
$ python3 -m ipykernel install --user --name=venvPy3

# from venv install kernel 
$ python3 -m ipykernel install --user --name=venvPy3

$ jupyter-kernelspec list
Available kernels:
  python3    /home/rolroralra/.local/share/jupyter/kernels/python3
  venvpy3    /home/rolroralra/.local/share/jupyter/kernels/venvpy3


Jupyter Tabnine Install

Details

$ pip3 install jupyter-tabnine --user

$ jupyter nbextension install --py jupyter_tabnine --user
Installing /home/rolroralra/.local/lib/python3.8/site-packages/jupyter_tabnine/static -> jupyter_tabnine
Making directory: /home/rolroralra/.local/share/jupyter/nbextensions/jupyter_tabnine/
Copying: /home/rolroralra/.local/lib/python3.8/site-packages/jupyter_tabnine/static/README.md -> /home/rolroralra/.local/share/jupyter/nbextensions/jupyter_tabnine/README.md
Copying: /home/rolroralra/.local/lib/python3.8/site-packages/jupyter_tabnine/static/main.css -> /home/rolroralra/.local/share/jupyter/nbextensions/jupyter_tabnine/main.css
Copying: /home/rolroralra/.local/lib/python3.8/site-packages/jupyter_tabnine/static/main.js -> /home/rolroralra/.local/share/jupyter/nbextensions/jupyter_tabnine/main.js
Copying: /home/rolroralra/.local/lib/python3.8/site-packages/jupyter_tabnine/static/tabnine.yaml -> /home/rolroralra/.local/share/jupyter/nbextensions/jupyter_tabnine/tabnine.yaml
- Validating: OK

    To initialize this nbextension in the browser every time the notebook (or other app) loads:

          jupyter nbextension enable jupyter_tabnine --user --py
          
$ jupyter nbextension enable --py jupyter_tabnine --user
Enabling notebook extension jupyter_tabnine/main...
      - Validating: OK
      
$ jupyter serverextension enable --py jupyter_tabnine --user
Enabling: jupyter_tabnine
- Writing config: /home/rolroralra/.jupyter
    - Validating...
      jupyter_tabnine  OK


Jupyter Server Issue

https://ipywidgets.readthedocs.io/en/latest/user_install.html

Details

$ journal -xe
Nov 26 09:40:50 rolroralra setroubleshoot[302737]: SELinux is preventing /usr/libexec/platform-python3.6 from write access on the file TS_MA_02.ipynb. For complete SELinux messages run: sealert -l 34fc2f0d->
Nov 26 09:40:50 rolroralra platform-python[302737]: SELinux is preventing /usr/libexec/platform-python3.6 from write access on the file TS_MA_02.ipynb.
                                                    
                                                    *****  Plugin catchall (100. confidence) suggests   **************************
                                                    
                                                    If you believe that platform-python3.6 should be allowed write access on the TS_MA_02.ipynb file by default.
                                                    Then you should report this as a bug.
                                                    You can generate a local policy module to allow this access.
                                                    Do
                                                    allow this access for now by executing:
                                                    # ausearch -c 'jupyter-noteboo' --raw | audit2allow -M my-jupyternoteboo
                                                    # semodule -X 300 -i my-jupyternoteboo.pp
                                                    
                                                  
$ ausearch -c 'jupyter-noteboo' --raw | audit2allow -M my-jupyternoteboo
******************** IMPORTANT ***********************
To make this policy package active, execute:

semodule -i my-jupyternoteboo.pp

$ semodule -X 300 -i my-jupyternoteboo.pp


Install Kite

Kite is IDE Plugin for python documentation about statiscs

https://www.kite.com/download/


Install statistics package by pip

$ pip install numpy matplotlib pandas seaborn
$ pip install GraphViz pydotplus mlxtend
$ pip install xlrd

How to install package in Jupyter Notebook

!pip install seaborn
!conda install seaborn -y

NGBoost

https://bkshin.tistory.com/entry/%EB%A8%B8%EC%8B%A0%EB%9F%AC%EB%8B%9D-16-NGBoost


Documentation List

pandas

https://pandas.pydata.org/pandas-docs/stable/reference/index.html

numpy

https://numpy.org/doc/1.19/

scipy

https://docs.scipy.org/doc/scipy/reference/#

matplotlib

https://matplotlib.org/3.3.3/contents.html#

statsmodel

https://www.statsmodels.org/stable/user-guide.html#

sklearn

https://scikit-learn.org/stable/modules/classes.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment