Skip to content

Instantly share code, notes, and snippets.

@liquidgenius
liquidgenius / amazon-rekognition.md
Created June 25, 2018 13:04 — forked from alexcasalboni/amazon-rekognition.md
Amazon Rekognition - Python Code Samples

Amazon Rekognition - Python Code Samples

  1. Labels Detection
  2. Faces Detection
  3. Faces Comparison
  4. Faces Indexing
  5. Faces Search
# 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!
@liquidgenius
liquidgenius / .gitignore
Created May 6, 2018 05:26 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
# uses the date_to_milliseconds and interval_to_milliseconds functions
# https://gist.github.com/sammchardy/3547cfab1faf78e385b3fcb83ad86395
# https://gist.github.com/sammchardy/fcbb2b836d1f694f39bddd569d1c16fe
from binance.client import Client
import time
def get_historical_klines(symbol, interval, start_str, end_str=None):
"""Get Historical Klines from Binance
def interval_to_milliseconds(interval):
"""Convert a Binance interval string to milliseconds
:param interval: Binance interval string 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w
:type interval: str
:return:
None if unit not one of m, h, d or w
None if string not in correct format
int value of interval in milliseconds
@liquidgenius
liquidgenius / dataframe_dataset_dataframe_roundtrip.py
Last active April 24, 2018 04:14
In Python, save a Pandas DataFrame to Sqlite using Dataset module and retrieve into Dataframe utilizing only Dataset function all().
import dataset
import pandas as pd
# create dataframe
df = pd.DataFrame()
names = ['Bob', 'Jane', 'Alice', 'Ricky']
ages = [31, 30, 31, 30]
df['names'] = names
df['ages'] = ages
@liquidgenius
liquidgenius / jamonek_robinhood_depaginate.py
Last active October 3, 2017 22:44
Convenience function for paginated data with Jamonek/Robinhood
https://github.com/Jamonek/Robinhood
def depaginate (rh_data):
res = rh_data['results']
while rh_data['next'] not in ['null', None]:
rh_data = rh.get_url(rh_data['next'])