#!/usr/bin/env python # coding: utf-8 #
# #

Visualizations of dataframes beyond simple tables

#
# In[ ]: import lux import pandas as pd # In[ ]: df = pd.read_csv("https://github.com/lux-org/lux-datasets/blob/master/data/hpi_cleaned.csv?raw=True") # In[ ]: df #
# #

Steering analysis with intent

#
# In[ ]: df.intent = ["Inequality","AvrgLifeExpectancy"] # In[ ]: df #
# #

Data Manipulation + Vis without changing a line of your Pandas code

#
# In[ ]: covid = pd.read_csv("https://github.com/lux-org/lux-datasets/blob/master/data/covid_cleaned.csv?raw=True") # In[ ]: df = covid.merge(df,left_on=["Entity","Code"],right_on=["Country","cca3"]) # In[ ]: df # # 🤔 Some interesting findings # In[ ]: df.intent = ["Inequality","AvrgLifeExpectancy"] df # #
# #

Exporting visualization insight to edit and share

#
# In[ ]: df # In[ ]: df.exported # In[ ]: print(df.exported[0].to_code("altair")) # We can copy-and-paste the output Altair code into a separate cell. Then let's tweak the plotting code a bit before sharing this insight with our colleagues. # In[ ]: import altair as alt c = "#e7298a" chart = alt.Chart(df,title="Check out this cool insight!").mark_circle().encode( x=alt.X('Inequality',scale=alt.Scale(domain=(0.04, 0.51)),type='quantitative', axis=alt.Axis(title='Inequality')), y=alt.Y('AvrgLifeExpectancy',scale=alt.Scale(domain=(48.9, 83.6)),type='quantitative', axis=alt.Axis(title='AvrgLifeExpectancy')) ) highlight = df[(df["Inequality"]>0.35)&(df["stringency_level"]=="High")] hchart = alt.Chart(highlight).mark_point(color=c,size=50,shape="cross").encode( x=alt.X('Inequality',scale=alt.Scale(domain=(0.04, 0.51)),type='quantitative', axis=alt.Axis(title='Inequality')), y=alt.Y('AvrgLifeExpectancy',scale=alt.Scale(domain=(48.9, 83.6)),type='quantitative', axis=alt.Axis(title='AvrgLifeExpectancy')), ) text = alt.Chart(highlight).mark_text(color=c,dx=-35,dy=0,fontWeight=800).encode( x=alt.X('Inequality',scale=alt.Scale(domain=(0.04, 0.51)),type='quantitative', axis=alt.Axis(title='Inequality')), y=alt.Y('AvrgLifeExpectancy',scale=alt.Scale(domain=(48.9, 83.6)),type='quantitative', axis=alt.Axis(title='AvrgLifeExpectancy')), text=alt.Text('Country') ) chart = chart.encode(color=alt.Color('stringency_level',type='nominal')) chart = chart.properties(width=160,height=150) (chart + hchart + text).configure_title(color=c)