Skip to content

Instantly share code, notes, and snippets.

View achagani's full-sized avatar

Aslam Chagani achagani

  • Deserve
  • San Jose, CA
View GitHub Profile

Keybase proof

I hereby claim:

  • I am achagani on github.
  • I am achagani (https://keybase.io/achagani) on keybase.
  • I have a public key ASAIK_sY55b25US3Tdm85m1sFB9mkV2no1t91rnB4UgP8go

To claim this, I am signing this object:

#source: http://www.swegler.com/becky/blog/2014/08/06/useful-pandas-snippets/
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
@achagani
achagani / gist:d5adf98935d93893c237
Created May 28, 2014 18:07
automatic virtualenv activation
# Python virtualenv
SRC_DIRECTORY="$HOME/programming"
venv () {
source $SRC_DIRECTORY/$1/bin/activate;
cd $SRC_DIRECTORY/$1;
# Then run "bash" again to reload the file, and you're done!
}
@achagani
achagani / copy_subdirectory_files
Created July 1, 2012 22:59
Python Script To Extract Files Files From Sub Directories
import os, shutil, glob
def copy_subdirectory_files (file_src, file_dst):
for file in os.listdir(file_src):
for font in glob.iglob(os.path.join(file_src, file, "*.ttf")):
print("Copying file: "+ font)
shutil.copy(os.path.join(file_src, file, font), file_dst)