I assembled a super quick cheatsheet of the most common Pandas, Numpy and Python tasks I tend to do. Let me know if I missed anything important in the comments below!
1 Data Structures1.1 Lists[]1.1.1 List Comprehensions - (do.. for)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @Name nvarchar(1000); | |
DECLARE @Sql nvarchar(1000); | |
DECLARE @Result int; | |
IF OBJECT_ID('tempdb..#myTable') IS NOT NULL | |
DROP TABLE #myTable | |
CREATE TABLE #myTable( | |
row INT, | |
query NVARCHAR(500)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import random | |
import numpy | |
def calculateCost(x,y): | |
return -0.0001*(( | |
math.fabs( | |
math.sin(x)*math.sin(y)*math.exp( | |
math.fabs( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import random | |
def calculateCost(x,y): | |
return -0.0001*(( | |
math.fabs( | |
math.sin(x)*math.sin(y)*math.exp( | |
math.fabs( | |
100 - math.sqrt(x**2+y**2)/math.pi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from skimage import color | |
def fft(length_x,width_y,v,y,image,inner=True): | |
expVector=np.exp(-2j*np.pi/width_y*(v@y)) if inner else np.exp(-2j*np.pi/length_x*(v@y)) | |
if inner: | |
return image @ expVector | |
else: | |
return expVector @ image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#sudo wget https://github.com/shiftkey/desktop/releases/download/release-2.1.0-linux1/GitHubDesktop-linux-2.1.0-linux1.deb | |
#sudo gdebi GitHubDesktop-linux-2.1.0-linux1.deb | |
# UPDATE (2021-03-05): Thanks to PaoloRanzi81's comment, the updated code is as follows https://gist.github.com/PaoloRanzi81 | |
sudo wget https://github.com/shiftkey/desktop/releases/download/release-2.6.3-linux1/GitHubDesktop-linux-2.6.3-linux1.deb | |
### Uncomment below line if you have not installed gdebi-core before | |
# sudo apt-get install gdebi-core | |
sudo gdebi GitHubDesktop-linux-2.6.3-linux1.deb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
manjaro | |
sudo pacman -Syu | |
#install lts kernel | |
#kde settings | |
# night mode | |
#ignore linux kernel updates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /tmp | |
wget https://assets.ubuntu.com/v1/fad7939b-ubuntu-font-family-0.83.zip | |
# you can check for newer versions | |
unzip fad7939b-ubuntu-font-family-0.83.zip | |
# then copy it to the font directory (applied to all users) | |
sudo cp -r ubuntu-font-family-0.83 /usr/share/fonts | |
fc-cache -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Show username after each process in nvidia-smi | |
# like: | |
# ... | |
# +------------------------------------------------------+ | |
# | Processes: GPU Memory | | |
# | GPU PID Type Process name Usage | | |
# |======================================================| | |
# | 0 150752 C python 830MiB | User: user1 | |
# | 1 2185 C /usr/bin/python 1090MiB | User: user2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nvidia-smi | tee /dev/stderr | awk '/ C / {print $3}' | xargs -r ps -up |
OlderNewer