ref: http://qiita.com/shizuma/items/027167c6257f1c9d2a6f
Install the latest version of anaconda (Python & assortment of various packages) via pyenv according to the above article. (Pyenv is put in with homebrew etc.)
pyenv install anaconda3-2.4.1
pyenv global anaconda3-2.4.1
Start up by moving to any folder
ipython notebook
Then, localhost: 8888
will be launched.
shortcuts
The following shortcuts can be used in the esc state. Vi command mode-like
Shortcuts | Features |
---|---|
h | help |
b | Create new cell |
dd | Delete current cell |
shift + enter | execution of current cell |
s | Save |
to y | code cell |
to m | markdown cell |
Use jupyterthemes.
pip install jupyterthemes
jt -t onedork
ref: http://qiita.com/shrkw/items/c38def7d60b0099b0c55
pip install pymysql
import pymysql
conn = pymysql.connect(host='localhost',
user='root',
password='',
db='mydatabase',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor)
I want to convert it to pandas dataframe as it is, so I use pandas sql library In addition, import the library that seems to be necessary
import pandas
from pandas.io import sql
import numpy
import pylab
import pymysql
import matplotlib.pyplot as plt
%matplotlib inline
users take information
users = sql.read_sql('''SELECT users.* FROM users''', conn)
pandas.DataFrame
Get basic statistics
users.describe()
Show a histogram list
users.hist()
Show user age as a histogram (30 bins)
# http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.hist.html
users.age.hist(bins=30)
Recommended Posts