Data Exploration Tool - Lantern Part 1
Overview¶
Lantern
is a python module for a toolkit collection for data exploration from a variety of dataset to visualization.
In this post, I will walk through the followings:
- How to set up
lantern
- What
lantern
can do- dataset
- plot (visualization)
- grid (interactive table view)
- widget
How to set up Lantern
¶
In [90]:
# !pip install pylantern
# !jupyter labextension install pylantern # for jupyter lab
In [30]:
import lantern as l
import matplotlib.pyplot as plt
%matplotlib inline
import cufflinks as cf
from plotly.offline import plot, download_plotlyjs, init_notebook_mode
cf.go_offline()
init_notebook_mode()
Person¶
In [4]:
# people from Mimesis - Fake Data Generator
l.person()
Out[4]:
In [5]:
# multiple records of person with locale
l.people(count=5, locale='en')
Out[5]:
In [6]:
# Visualize people
people = l.people(count=50, locale='en')
people['gender'].value_counts().plot(kind='bar');
In [7]:
people['age'].hist();
In [8]:
people['occupation'].value_counts().plot(kind='bar');
In [9]:
people['university'].value_counts().plot(kind='bar');
Company¶
In [10]:
# company
l.company()
Out[10]:
In [11]:
# Multiple companies
l.companies(count=5)
Out[11]:
In [12]:
# Visualize comapanies
companies = l.companies(count=50)
companies.columns.values
Out[12]:
In [13]:
companies['exchange'].value_counts().plot(kind='bar');
In [14]:
companies['industry'].value_counts().plot(kind='bar');
Financial¶
In [15]:
[l.ticker(country='us') for i in range(10)]
Out[15]:
In [16]:
[l.currency() for i in range(10)]
Out[16]:
In [17]:
l.trades(count=5)
Out[17]:
In [18]:
# Visualization
trades = l.trades(count=50)
trades['price'].hist(bins=50).plot();
In [19]:
trades['sector'].value_counts().plot(kind='bar');
In [20]:
### General Purpose
l.superstore(count=5)
Out[20]:
In [21]:
# Visualization
superstore=l.superstore(count=50)
superstore['Country'].value_counts().plot(kind='bar');
In [22]:
superstore['Profit'].plot(kind='hist');
In [23]:
superstore['Sales'].plot(kind='hist');
In [24]:
superstore['State'].value_counts().plot(kind='bar');
Cufflinks Data¶
Area¶
In [25]:
l.area().head()
Out[25]:
In [39]:
fig = l.area().iplot(kind='area', fill=True, asFigure=True)
# plot(fig, include_plotlyjs=False, output_type='div')
Bar¶
In [27]:
l.bar().head()
Out[27]:
In [33]:
fig = l.bar().iplot(kind='bar', asFigure=True)
Box¶
In [98]:
l.box().head()
Out[98]:
In [43]:
fig = l.box().iplot(kind='box', asFigure=True)
# plot(fig, include_plotlyjs=False, output_type='div')
Comments
Comments powered by Disqus