Skip to content

Commit d8a1ee2

Browse files
committed
chore: add examples to the repository
1 parent 64ecb12 commit d8a1ee2

File tree

11 files changed

+91
-3
lines changed

11 files changed

+91
-3
lines changed

docs/Usage/Examples.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ t
164164

165165
{% codetabs name="Python", type="py" -%}
166166
from IPython.display import Image
167-
Image('http://jakevdp.github.com/figures/xkcd_version.png')
167+
Image('https://cloud.githubusercontent.com/assets/836375/15271096/98e4c102-19fe-11e6-999a-a74ffe6e2000.gif')
168168
{%- endcodetabs %}
169169

170170
## HTML
171171

172172
{% codetabs name="Python", type="py" -%}
173-
from IPython.display import HTML
174-
HTML("<iframe src='https://nteract.io/' width='900' height='490'></iframe>")
173+
from IPython.display import IFrame
174+
IFrame('https://nteract.io/', width='900', height='490')
175175
{%- endcodetabs %}
176176

177177
## Plain Text

examples/dataframes.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# on Windows: open the shell as admin then: `pip install numpy pandas`
2+
# on Unix: `sudo pip install numpy pandas`
3+
# You might need to reload Atom after installation of dependencies if they are not found
4+
5+
import numpy as np
6+
import pandas as pd
7+
8+
df = pd.DataFrame({
9+
'A': 1.,
10+
'B': pd.Timestamp('20130102'),
11+
'C': pd.Series(1, index=list(range(4)), dtype='float32'),
12+
'D': np.array([3] * 4, dtype='int32'),
13+
'E': pd.Categorical(["test", "train", "test", "train"]),
14+
'F': 'foo'
15+
})
16+
17+
df

examples/html.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from IPython.display import IFrame
2+
IFrame('https://nteract.io/', width='900', height='490')

examples/images.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from IPython.display import Image
2+
Image('https://cloud.githubusercontent.com/assets/836375/15271096/98e4c102-19fe-11e6-999a-a74ffe6e2000.gif')

examples/json.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from IPython.display import JSON
2+
3+
data = {"foo": {"bar": "baz"}, "a": 1}
4+
JSON(data)

examples/matplot-pyqt.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# on Windows: open the shell as admin then: `pip install pyqt5 matplotlib numpy`
2+
# on Unix: `sudo pip install pyqt5 matplotlib numpy`
3+
# You might need to reload Atom after installation of dependencies if they are not found
4+
5+
import matplotlib
6+
matplotlib.use('Qt5Agg')
7+
8+
import matplotlib.pyplot as plt
9+
import numpy as np
10+
11+
t = np.linspace(0, 20, 500)
12+
plt.plot(t, np.sin(t))

examples/numpy-matplot.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# on Windows: open the shell as admin then: `pip install matplotlib numpy nbformat`
2+
# on Unix: `sudo pip install matplotlib numpy nbformat`
3+
# You might need to reload Atom after installation of dependencies if they are not found
4+
5+
import numpy as np
6+
import matplotlib.pyplot as plt
7+
8+
t = np.linspace(0, 20, 500)
9+
plt.plot(t, np.sin(t))

examples/pandas.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import pandas as pd
2+
3+
pd.options.display.html.table_schema = True
4+
pd.options.display.max_rows = None
5+
6+
iris_url = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
7+
8+
df1 = pd.read_csv(iris_url)
9+
10+
df1

examples/plotly.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# on Windows: open the shell as admin then: `pip install plotly nbformat`
2+
# on Unix: `sudo pip install plotly nbformat`
3+
# You might need to reload Atom after installation of dependencies if they are not found
4+
5+
from plotly import offline
6+
offline.init_notebook_mode()
7+
8+
offline.iplot([{"y": [1, 2, 1]}])

examples/text.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Hello World!")

0 commit comments

Comments
 (0)