This file contains hidden or 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
fortune | ponysay |
This file contains hidden or 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 docx | |
from subprocess import Popen, PIPE | |
def doc_to_txt(filename): | |
''' | |
Get the path of a Word document and returns the text of this document | |
:param filename: The filename of the doc or docx document | |
:type filename: str | |
:return: The text of the document |
This file contains hidden or 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
# List the column of a DataFrame | |
list(my_dataframe) | |
# Rename columns | |
my_dataframe.columns = ['new_name_1', 'new_name_1'] |
This file contains hidden or 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
# List all indices: | |
curl -XGET 'localhost:9200/_cat/indices?v&pretty' | |
# Delete the index (here `myindex`): | |
curl -XDELETE 'localhost:9200/myindex?pretty' |
This file contains hidden or 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
# Launch the mongo shell: | |
mongo | |
# List all databases: | |
show dbs | |
# Switch to the database you want to drop (here `mydb`): | |
use mydb | |
# Drop it: |
This file contains hidden or 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
# Create a new virtual environment (source: https://github.com/ContinuumIO/anaconda-issues/issues/305) | |
conda create -n my-venv python=3.4 | |
source activate my-venv | |
# List all virtual environments (source: https://conda.io/docs/using/envs.html#list-all-environments) | |
conda info --envs |
This file contains hidden or 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 os | |
from PIL import Image | |
# Parameters to be specified: | |
origin_folder = "path" | |
destination_folder = "path" | |
top_ratio = 0.15 | |
# Create the destination folder if it doesn't exist | |
if not os.path.exists(destination_folder): |