Skip to content

Instantly share code, notes, and snippets.

View vetional's full-sized avatar

Prateek Shrivastava vetional

  • Amazon
  • Hydrabad
  • 11:19 (UTC +05:30)
View GitHub Profile
@vetional
vetional / mysql-pandas-import.py
Created April 8, 2018 15:08 — forked from stefanthoss/mysql-pandas-import.py
Import data from a MySQL database table into a Pandas DataFrame using the pymysql package.
import pandas as pd
import pymysql
from sqlalchemy import create_engine
engine = create_engine('mysql+pymysql://<user>:<password>@<host>[:<port>]/<dbname>')
df = pd.read_sql_query('SELECT * FROM table', engine)
df.head()
@vetional
vetional / percent.c
Last active August 24, 2016 16:00 — forked from anonymous/percent.c
#ifdef __ANDROID__
#include "jni.h"
#include "android/log.h"
#define LOG_TAG "psx"
#define PRINTMSGS(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#endif
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
@vetional
vetional / beautiful_idiomatic_python.md
Created July 24, 2016 10:04 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@vetional
vetional / one-hot.py
Created May 15, 2016 14:35 — forked from ramhiser/one-hot.py
Apply one-hot encoding to a pandas DataFrame
import pandas as pd
import numpy as np
from sklearn.feature_extraction import DictVectorizer
def encode_onehot(df, cols):
"""
One-hot encoding is applied to columns specified in a pandas DataFrame.
Modified from: https://gist.github.com/kljensen/5452382

###SSH into a remote machine###

ssh [email protected]
#or by ip address
ssh [email protected]

exit: exit ###Install Something###

#If it's a new server, update apt-get first thing