A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
# Initialize the scroll | |
page = es.search( | |
index = 'yourIndex', | |
doc_type = 'yourType', | |
scroll = '2m', | |
search_type = 'scan', | |
size = 1000, | |
body = { | |
# Your query's body | |
}) |
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() |
# coding: utf8 | |
""" | |
Goal: import csv to database. | |
pip install pandas, numpy | |
""" | |
import pandas | |
import numpy as np |
# -*- coding: utf-8 -*- | |
# import pandas and numpy package | |
import numpy as np | |
import pandas as pd | |
# List unique values in a DataFrame column | |
df['Column Name'].unique() | |
# To extract a specific column (subset the dataframe), you can use [ ] (brackets) or attribute notation. |
import pandas as pd | |
# Read file | |
results = pd.read_csv("/tmp/data.csv", encoding='utf-8',sep=',', quoting=csv.QUOTE_ALL) | |
# Print rows | |
for row in results: | |
print(row) | |
# Iterate over rows |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
# Redis Cheatsheet | |
# All the commands you need to know | |
redis-server /path/redis.conf # start redis with the related configuration file | |
redis-cli # opens a redis prompt | |
# Strings. |
<?php | |
function array_keys_multi(array $array) | |
{ | |
$keys = array(); | |
foreach ($array as $key => $value) { | |
$keys[] = $key; | |
if (is_array($array[$key])) { | |
$keys = array_merge($keys, array_keys_multi($array[$key])); |
sudo apt-get install python-setuptools
wget http://downloads.sourceforge.net/project/s3tools/s3cmd/1.5.0-alpha1/s3cmd-1.5.0-alpha1.tar.gz
tar xvfz s3cmd-1.5.0-alpha1.tar.gz
cd s3cmd-1.5.0-alpha1
python setup.py install
s3cmd --configure
When hosting our web applications, we often have one public IP
address (i.e., an IP address visible to the outside world)
using which we want to host multiple web apps. For example, one
may wants to host three different web apps respectively for
example1.com
, example2.com
, and example1.com/images
on
the same machine using a single IP address.
How can we do that? Well, the good news is Internet browsers