Play with Jupyter Notebook (IPython Notebook)

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

Change theme

Use jupyterthemes.

pip install jupyterthemes
jt -t onedork

Connect to mysql and view data

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)

Acquisition of user information

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

Play with Jupyter Notebook (IPython Notebook)
Use apache Spark with jupyter notebook (IPython notebook)
Rich cell output with Jupyter Notebook (IPython)
How to debug with Jupyter or iPython Notebook
Graph drawing with jupyter (ipython notebook) + matplotlib + vagrant
Using Graphviz with Jupyter Notebook
Use pip with Jupyter Notebook
Use Cython with Jupyter Notebook
Run Apache-Spark with IPython Notebook
Graph drawing with IPython Notebook
Use Bokeh with IPython Notebook
EC2 provisioning with Vagrant + Jupyter (IPython Notebook) on Docker
Allow external connections with jupyter notebook
R & D life with iPython notebook
Formatting with autopep8 on Jupyter notebook
Visualize decision trees with jupyter notebook
Make a sound with Jupyter notebook
Use markdown with jupyter notebook (with shortcut)
Add more kernels with Jupyter Notebook
Build IPython Notebook environment with boot2docker
Convenient analysis with Pandas + Jupyter notebook
Spark play with WSL anaconda jupyter (2)
Play with Prophet
Use nb extensions with Anaconda's Jupyter notebook
Jupyter Notebook memo
Introducing Jupyter Notebook
Play with PyTorch
I want to blog with Jupyter Notebook
Use Jupyter Lab and Jupyter Notebook with EC2
Try SVM with scikit-learn on Jupyter Notebook
Powerful Jupyter Notebook
Play with 2016-Python
How to use jupyter notebook with ABCI
Linking python and JavaScript with jupyter notebook
"LIVE" HTML presentation with IPython 3.0.0-dev, IPython Notebook
Jupyter notebook password
Jupyter Notebook memo
Play with CentOS 8
ipython notebook installation
IPython Notebook Recommendations
[Jupyter Notebook memo] Display kanji with matplotlib
Play with Pyramid
Play with Fathom
When Html cannot be output with Jupyter Notebook
Analytical environment construction with Docker (jupyter notebook + PostgreSQL)
Data analysis for improving POG 2 ~ Analysis with jupyter notebook ~
Enable Jupyter Notebook with conda on remote server
Try using conda virtual environment with Jupyter Notebook
Fill the browser with the width of Jupyter Notebook
Create a table of contents with IPython notebook
Candlestick with plotly + Jupyter
Get started Jupyter Notebook
Play with Othello (Reversi)
3 Jupyter notebook (Python) tricks
Start IPython with virtualenv
R environment construction with Jupyter (formerly IPython notebook) (on OS X El Capitan 10.11.3)
Make slides with iPython
Remotely connect IPython notebook
Use nim with Jupyter
[Cloud103] # 3 Jupyter Notebook again
Virtual environment construction with Docker + Flask (Python) + Jupyter notebook