X4DS
Python & Julia port of codes in the following excellent R books (including exercises):
Tidyverse port also will be included.
Python Stack | Julia Stack | ||
Language Version | v3.9 | v1.6 | |
Data Processing |
Basic | ||
Enhanced | |||
Visualization | Basic |
|
|
Enhanced | |||
Machine Learning |
Basic |
|
|
Probablistic Programming |
Basic |
|
Code Styles
basics
- use
enumerate()
rather thanrange(len())
xs = range(3)
# good
for ind, x in enumerate(xs):
print(f'{ind}: {x}')
# bad
for i in range(len(xs)):
print(f'{i}: {xs[i]}')
matplotlib
- use
Axes
object rather thanFigure
object
# good
_, axes = plt.subplots(1, 2, constrained_layout=True)
axes[0].plot(x1, y1)
axes[1].hist(x2, y2)
# bad
plt.subplot(121)
plt.plot(x1, y1)
plt.subplot(122)
plt.hist(x2, y2)
- use
set()
method rather thanset_*()
method
# good
ax.set(xlabel='x', ylabel='y')
# bad
ax.set_xlabel('x')
ax.set_ylabel('y')