#!/usr/bin/env python # coding: utf-8 # # Default widgets for modules # # Define an `_ipython_display_` function that takes no arguments to show a default display for the module. # # ![image](https://user-images.githubusercontent.com/4236275/45131612-bca6fa00-b15b-11e8-9b0b-76c80d4cbce5.png) # # In[35]: get_ipython().run_line_magic('reload_ext', 'deathbeds.__Custom_display_formatting') from deathbeds.__Custom_display_formatting import Row, Column from pandas import * from poser import * import os # In this example we'll explore the [Flowers datasets on Kaggle](https://www.kaggle.com/alxmamaev/flowers-recognition/version/2#). # In[36]: flowers = λ.Path('data/flowers/').Path.glob('*').map(λ.Path.glob('*')).concat().list().pandas.Series()() flowers = flowers.apply(str).str.lstrip('data'+os.sep).str.split(os.sep, expand=True).set_index(flowers).rename(columns={ 0:'label', 1: 'type', 2: 'file'}) # In[37]: from IPython.display import display # In[38]: def _ipython_display_(): from ipywidgets import interact @interact def _(type=list(flowers.type.unique()), rows=3, columns=4): display(Column([Row([str(x) for x in flowers[flowers.type.eq(type)].sample(columns).index]) for row in range(rows)])) # In[39]: __import__(__name__) # In[ ]: # In[ ]: