<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <img src='rc_logo.png' style="height
Step1:  Locally and Remote
Run locally
Connect to the cloud (e.g AWS)
Connect to supercomputer (e.g. XSEDE Resource)
Add compute power
Step2:  Plot a Histogram of x
Step3:  Customizable
Custom CSS
Custom javascript libraries
Create your own output format.
Tools and workflow
Magic Commands
Built-in useful functions
% line commands
%% cell commands
Step4:  Other Languages
Step5:  Keep it all together
Step6:  NBconvert examples
HTML
PDF (print) - you have to have LaTex installed
Slides
Dynamic Slides
ReStructured Text (sphinx)
<ASSISTANT_TASK:>
Python Code:
2+4
print("hello")
print("Hello world!")
Explanation: <img src='rc_logo.png' style="height:75px">
Efficient Data Analysis with the IPython Notebook
<img src='data_overview.png' style="height:500px">
Objectives
Become familiar with the IPython Notebook.
Introduce the IPython landscape.
Getting started with exploratory data analysis in Python
Conducting reproducible data analyis and computing experiments
How do you currently:
wrangle data?
visualize results?
Analysis: machine learning, stats
Parallel computing
Big data
What is Python?
<blockquote>
<p>
Python is a general-purpose programming language that blends procedural, functional, and object-oriented paradigms
<p>
Mark Lutz, <a href="http://www.amazon.com/Learning-Python-Edition-Mark-Lutz/dp/1449355730">Learning Python</a>
</blockquote>
Simple, clean syntax
Easy to learn
Interpreted
Strong, dynamically typed
Runs everywhere: Linux, Mac, and Windows
Free and open
Expressive: do more with fewer lines of code
Lean: modules
Options: Procedural, object-oriented, and functional.
Abstractions
Python provides high-level abstraction
Performance can be on par with compiled code if right approach is used
<img src="https://s3.amazonaws.com/research_computing_tutorials/matrix_multiply_compare.png" style="margin:5px auto; height:400px; display:block;">
IPython and the IPython Notebook
IPython
Platform for interactive computing
Shell or browser-based notebook
Project Jupyter
Language independent notebook
Can be used with R, Julia, bash ...
IPython Notebook
http://blog.fperez.org/2012/01/ipython-notebook-historical.html
Interactive web-based computing, data analysis, and documentation.
One document for code and output
Run locally and remote
Document process
Share results
<img src='traditional_python.png'>
<img src='ipython-notebook.png'>
Integrate Code and Documentation
Data structure ouput
Inline plots
Conversation sytle programming (Literate programming)
Telling a data story
Great for iterative programming.
Data analysis
Quick scripts
Prototyping
2 type of cells:
Markdown for documentation
Code for execution programs
End of explanation
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
x = np.random.randn(10000)
print(x)
Explanation: Locally and Remote
Run locally
Connect to the cloud (e.g AWS)
Connect to supercomputer (e.g. XSEDE Resource)
Add compute power:
mpi4py
IPython Parallel
spark big distributed data
Numbapro GPU
...
Documentation and Sharing
<img src='ipython-notebook-sharing.png'>
Keyboard Shortcuts
<img src='ipython-notebook-keyboard.png'>
Markdown and LaTeX
Markdown
Latex $y = \sqrt{a + b}$
Images
&lt;img src='https://s3.amazonaws.com/research_computing_tutorials/monty-python.png' width="300"&gt;
This is an image:
<img src='https://s3.amazonaws.com/research_computing_tutorials/monty-python.png' width="300">
Embeded Plots
End of explanation
plt.hist(x, bins=50)
plt.show()
Explanation: Plot a Histogram of x
End of explanation
%lsmagic
%timeit y = np.random.randn(100000)
%ll
Explanation: Customizable
Custom CSS
Custom javascript libraries
Create your own output format.
Tools and workflow
Magic Commands
Built-in useful functions
% line commands
%% cell commands
End of explanation
%%bash
ls -l
files = !ls # But glob is a better way
print files[:5]
Explanation: Other Languages: Bash
End of explanation
%%writefile example.cpp
#include <iostream>
int main(){
    std::cout << "hello from c++" << std::endl;
}
%ls
%%bash
g++ example.cpp -o example
./example
Explanation: Keep it all together
End of explanation
!ipython nbconvert --to 'PDF' 01_introduction-IPython-notebook.ipynb
!open 01_introduction-IPython-notebook.pdf
Explanation: NBconvert examples
HTML
PDF (print) - you have to have LaTex installed
Slides
Dynamic Slides
ReStructured Text (sphinx)
End of explanation
<END_TASK>