Skip to content

Instantly share code, notes, and snippets.

View cjauvin's full-sized avatar

Christian Jauvin cjauvin

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from sklearn.preprocessing import LabelEncoder
import pandas as pd
import bisect
le = LabelEncoder()
train_c = le.fit_transform(['a', 'b', 'c', 'a'])
test_c = pd.Series(['a', 'b', 'c', 'd']).map(
lambda s: '<unk>' if s not in le.classes_ else s
)
from sklearn.preprocessing import LabelEncoder
import pandas as pd
import bisect
le = LabelEncoder()
train_c = le.fit_transform(['a', 'b', 'c', 'a'])
test_c = pd.Series(['a', 'b', 'c', 'd']).map(
lambda s: '<unk>' if s not in le.classes_ else s
)
from sklearn.preprocessing import LabelEncoder
import pandas as pd
import bisect
le = LabelEncoder()
train_c = le.fit_transform(['a', 'b', 'c', 'a'])
test_c = pd.Series(['a', 'b', 'c', 'd']).map(lambda s: '<unk>' if s not in le.classes_ else s)
print(test_c.tolist()) # ['a', 'b', 'c', '<unk>']
# Get everything! handles every single possible select query required
# by the app..
# note: field_map is not the nicest thing in the world..
# it should be replaced by something wiser sometime!
def query(g, params, tables, query_fields=None, query_op='ilike', what='*',
join=None, where=None, field_map=None, group_by=None, order_by=None,
include_total=True, debug=False):
if query_fields is None:
query_fields = ()
if join is None:
import qualified Data.Sequence as Sequence
fromList = Sequence.fromList
index = Sequence.index
update = Sequence.update
data Color = Red |
Green |
Blue |
Yellow
@app.route('/upload_data', methods=['POST'])
def upload_data():
cur = conn.cursor()
f = request.files['file']
df = pd.DataFrame.from_csv(f, index_col=False)
df.hashtags = df.hashtags.map(ast.literal_eval)
screen_name = df.screen_name.unique()
assert len(screen_name) == 1
screen_name = screen_name[0]
cur.execute('delete from tweets where screen_name = %s', [screen_name])
- name: Run whoami to get ssh user
command: whoami
register: whoami_output
- name: Set user fact
set_fact:
user: "{{ whoami_output.stdout }}"
- name: test it!
debug: msg="{{ user }}" # should be vagrant on a VM, or your remote user for whatever else