Skip to content

Instantly share code, notes, and snippets.

@katronai
katronai / looping.py
Created March 3, 2020 22:44
Looping in Python 3.
# Loop through list
for item in list:
print(item)
# Loop through list with index
for index, item in enumerate(list):
print(index, item)
# Loop through dictinary:
for key, value in dict.items():
@katronai
katronai / pandas.md
Last active March 12, 2020 20:38
Pandas operations

Importing Data

  • Dictionary to DataFrame
df = pd.Dataframe(my_dict)
  • Dictionary to DataFrame with row labels
@katronai
katronai / strings.py
Last active March 3, 2020 21:17
String formatting and operations in Python 3.
# Print without line break
print('*', end='')
# Print without spaces between arguments
print('a', 'b', 'c', sep='')
# Flush the output in case of buffering problems
print('*', end='', flush=True)
# String formatting: https://docs.python.org/3/library/string.html#formatstrings
@katronai
katronai / bash-commands.md
Last active December 26, 2020 23:43
These are the most useful commands for myself working on Terminal

Bash Commands

  • cd ..
    Change to the parent directory

  • cd -
    Change to the previous directory

  • open .
    Open current folder in Finder

@katronai
katronai / imputer.py
Last active March 3, 2020 22:57
Impute missing values
imputer = Imputer(missing_values='NaN', strategy='mean', axis=0)
# imputer = Imputer(missing_values='NaN', strategy='median', axis=0)
# imputer = Imputer(missing_values='NaN', strategy='most_frequent', axis=0)
# imputer = Imputer(missing_values=0, strategy='mean', axis=0)
X_train = imputer.fit_transform(X_train)
X_test = imputer.transform(X_test)
@katronai
katronai / tweets-by-date.py
Last active March 3, 2020 23:04
Search tweets by date from Twitter using tweepy
# The following code fetches the most recent 1000 mentions of 'python'.
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
import tweepy
import time
ckey ='x'
csecret = 'x'
@katronai
katronai / windows-commands.txt
Created March 17, 2017 08:06
Windows command line commands
Service info
sc queryex servicename
Kill service
taskkill /f /pid mypid
System file checker
sfc /scannow
Available physical memory
@katronai
katronai / git-commands.sh
Last active March 3, 2020 23:28
Git commands
Initialize a new git repository \
`git init`
Stage files \
`git add .`
Commit messages \
`git commit -m <commit message>`
Clone remote repository \
@katronai
katronai / windows-run-commands.txt
Created March 17, 2017 07:47
Windows 10 run commands
Computer management
compmgmt.msc
Control panel
control
Device manager
devmgmt.msc
Disk cleanup
@katronai
katronai / visual-studio-shortcuts.txt
Last active March 17, 2017 08:57
Visual Studio shortcuts
Show tips
Ctrl + .
Peak view
Alt + F12
Show Solution Explorer
Ctrl + Alt + L
Display quick info