Skip to content

Instantly share code, notes, and snippets.

import argparse
import sqlite3 as lite
import os
def _open_db(db):
try:
con = lite.connect(db)
cur = con.cursor()
return (cur,con)
except lite.Error as e:
@phdkiran
phdkiran / csv_to_elastic_search_bulk_insert.py
Last active August 29, 2015 14:26 — forked from clemsos/csv_to_elastic_search_bulk_insert.py
Elastic Search : index large csv files with Python Pandas
from pyelasticsearch import ElasticSearch
import pandas as pd
from time import time
root_path="/home/clemsos/Dev/mitras/"
raw_data_path=root_path+"data/"
csv_filename="week10.csv"
t0=time()
@phdkiran
phdkiran / centos_python_env_setup
Last active May 25, 2016 15:43 — forked from iDevPy/centos_python_env_setup
CentOS 7: Install Python 3.5.1, pip, virtualenv, and virtualenvwrapper on CentOS. Run this script as "root (sudo su -)" without sudo.
#!/bin/bash
#####################################################################
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
# Copyright (C) 2015 Ivan Rivera
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
@phdkiran
phdkiran / .gitignore
Created July 7, 2016 23:38 — forked from karmi/.gitignore
Example Nginx configurations for Elasticsearch
nginx/
!nginx/.gitkeep
!nginx/logs/.gitkeep
src/
tmp/
@phdkiran
phdkiran / 03_basic_regex_homework.ipynb
Last active November 3, 2016 20:25
MLtext3/submissions/03_basic_regex_homework.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@phdkiran
phdkiran / 04_intermediate_regex_homework-Copy1.ipynb
Last active November 4, 2016 03:56
MLtext3/submissions/04_intermediate_regex_homework-Copy1.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Homework with Hacker News data\n",
"\n",
"## About Hacker News\n",
"\n",
@phdkiran
phdkiran / stackexchange-kaggle-submission.ipynb
Last active November 17, 2016 03:47
MLtext3/submissions/stackexchange-kaggle-Copy3.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@phdkiran
phdkiran / snakecoin-server-full-code.py
Created November 15, 2017 22:19 — forked from aunyks/snakecoin-server-full-code.py
The code in this gist isn't as succinct as I'd like it to be. Please bare with me and ask plenty of questions that you may have about it.
from flask import Flask
from flask import request
import json
import requests
import hashlib as hasher
import datetime as date
node = Flask(__name__)
# Define what a Snakecoin block is
class Block:
@phdkiran
phdkiran / useful_pandas_snippets.py
Created December 21, 2017 17:38 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
# h/t @makmanalp for the updated syntax!
df['Column Name'].unique()
# Convert Series datatype to numeric (will error if column has non-numeric values)
# h/t @makmanalp
pd.to_numeric(df['Column Name'])
# Convert Series datatype to numeric, changing non-numeric values to NaN
# h/t @makmanalp for the updated syntax!