Skip to content

Commit f18a1a7

Browse files
authored
Add jupyter template
1 parent 36101ca commit f18a1a7

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# ---
2+
# jupyter:
3+
# jupytext:
4+
# formats: ipynb,py:percent
5+
# text_representation:
6+
# extension: .py
7+
# format_name: percent
8+
# format_version: '1.3'
9+
# jupytext_version: 1.18.1
10+
# kernelspec:
11+
# display_name: Python 3 (ipykernel)
12+
# language: python
13+
# name: python3
14+
# ---
15+
16+
# %% [markdown]
17+
# # Title
18+
#
19+
20+
# %% [markdown]
21+
# Description with link to ticket.
22+
#
23+
24+
# %%
25+
# %load_ext autoreload
26+
# %autoreload 2
27+
# %matplotlib inline
28+
29+
# %%
30+
import logging
31+
import pathlib
32+
33+
import dotenv
34+
import matplotlib
35+
import matplotlib.pyplot as plt
36+
import nest_asyncio
37+
import numpy as np
38+
import pandas as pd
39+
import seaborn as sns
40+
import ydata_profiling
41+
from IPython.core.interactiveshell import InteractiveShell
42+
from IPython.display import display, display_markdown, Markdown
43+
from markupspace import escape
44+
from pqdm.processes import pqdm
45+
# If you want threads instead:
46+
# from pqdm.threads import pqdm
47+
from tqdm.notebook import tqdm
48+
49+
# %%
50+
# pd.options.mode.chained_assignment = None
51+
InteractiveShell.ast_node_interactivity = "all"
52+
# InteractiveShell.ast_node_interactivity = "last_expr"
53+
tqdm.pandas()
54+
55+
# %%
56+
57+
def printmd(string):
58+
display(Markdown(escape('# <span style="color:red">'+string+'</span>')))
59+
60+
display_markdown(escape('''## heading
61+
- ordered
62+
- list
63+
64+
The table below:
65+
66+
| id |value|
67+
|:---|----:|
68+
| a | 1 |
69+
| b | 2 |
70+
'''), raw=True)
71+
72+
# %% [markdown]
73+
# Blue Alert Box: info.
74+
# <div class="alert alert-block alert-info">
75+
# <b>Tip:</b> Use blue boxes (alert-info) for tips and notes.
76+
# If it's a note, you don't have to include the word "Note".
77+
# </div>
78+
#
79+
# # Yellow Alert Box: Warning.
80+
# <div class="alert alert-block alert-warning">
81+
# <b>Example:</b> Yellow Boxes are generally used to include additional examples or mathematical formulas.
82+
# </div>
83+
#
84+
# # Green Alert Box: Success.
85+
# <div class="alert alert-block alert-success">
86+
# Use green box only when necessary like to display links to related content.
87+
# </div>
88+
#
89+
# # Red Alert Box: Danger.
90+
# <div class="alert alert-block alert-danger">
91+
# It is good to avoid red boxes but can be used to alert users to not delete some important part of code etc.
92+
# </div>
93+
94+
# %%
95+
logger = logging.getLogger(__name__)
96+
logger.setLevel(logging.INFO)
97+
handler = logging.StreamHandler()
98+
# Add the handler to the logger
99+
logger.addHandler(handler)
100+
101+
matplotlib.use('nbagg')
102+
# prettier plots
103+
plt.style.use('ggplot')
104+
# larger plots - two different ways.
105+
matplotlib.rc('figure', figsize=(15, 10))
106+
plt.rcParams["figure.dpi"] = 90
107+
108+
# larger fonts
109+
sns.set_context('notebook', font_scale=1.5)
110+
111+
dotenv.load_dotenv()
112+
nest_asyncio.apply()
113+
114+
np.set_printoptions(precision=4)
115+
np.set_printoptions(suppress=True)
116+
pd.set_option('display.max_rows', 500)
117+
pd.options.display.max_columns = 50
118+
pd.options.display.max_rows = 100
119+
pd.options.display.max_colwidth = 80
120+
# Adjust the number of columns profiled and displayed by the `info()` method.
121+
pd.options.display.max_info_columns = 150
122+
# Adjust the number of decimals to be displayed in a DataFrame.
123+
pd.options.display.precision = 15
124+
# Adjust the display format in a DataFrame.
125+
# pd.options.display.float_format = '{:.2f}%'.format
126+
# Prints and parses dates with the year first.
127+
pd.options.display.date_yearfirst = True
128+
129+
InteractiveShell.ast_node_interactivity = "all"
130+
131+
data_dir = pathlib.Path.cwd().parent / "data"
132+
133+
def square(a):
134+
return a*a
135+
136+
result = pqdm([1, 2, 3, 4, 5], square, n_jobs=2)
137+
138+
profile = ydata_profiling.ProfileReport(df, title="Profiling Report")
139+
profile.to_notebook_iframe()
140+
# profile.to_widgets()
141+
# profile.to_html('profile.html')

0 commit comments

Comments
 (0)