This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import progressbar | |
pbar = progressbar.ProgressBar(maxval=len(object)) | |
pbar.start() | |
for i in range(len(object)): | |
pbar.update(i) | |
pbar.finish() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pprint | |
import pprintpprint(example_json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alter table table_name add constraint table_name_column_name_fkey foreign key (column_name) references other_table_name (other_column_name) on delete cascade; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pg_dump -Fc -v -U user_name -d db_name -t table_name > /path/to/file.bak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
where array_column && array['string1', 'string2']::text[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alter table table_name drop column_name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open(path_to_file, 'w').write(json.dumps(data)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = json.loads(open(path_to_file, 'r').read()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
counts = [10, 8, 6, 14] | |
weights = np.ones_like(counts) / float(len(counts)) | |
plt.figure(figsize=(10, 5)) | |
plt.hist(counts, bins=range(1, max(counts)+2), align='left', weights=weights) | |
plt.xticks(range(1, max(counts)+1)) | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Visualise given word embeddings | |
# words is a list of words | |
# data is the vector representation of each word | |
# Train the algorithm | |
from sklearn.manifold import TSNE | |
vis_algo = TSNE(random_state=0, verbose=10, init='pca', n_iter=200) | |
vis = vis_algo.fit_transform(data) | |
# Plot the resulting visualisation |
OlderNewer