Package: dx
dxThis package provides convenient formatting and IPython display formatter registration for tabular data and DEX media types.A Pythonic Data Explorer, open sourced with ❤️ byNoteable, a collaborative notebook platform that enables teams to use and visualize data, together.RequirementsPython 3.8+InstallationPoetrypoetryadddxThen import the package:importdxPippipinstalldxThen import the package:importdxUsageThedxlibrary currently enables DEX media type visualization of pandasDataFrameandSeriesobjects, as well as numpyndarrayobjects. This can be handled in two ways:explicitdx.display()callssetting thedisplay_modeto update the IPython display formatter for a sessionWithdx.display()dx.display()will display a single dataset using the DEX media type. It currently supports:pandasDataFrameobjectsimportpandasaspdimportrandomdf=pd.DataFrame({'random_ints':[random.randint(0,100)for_inrange(500)],'random_floats':[random.random()for_inrange(500)],})dx.display(df)tabular data asdictorlisttypesdx.display([[1,5,10,20,500],[1,2,3,4,5],[0,0,0,0,1]]).csvor.jsonfilepathsdf=dx.random_dataframe()df.to_csv("dx_docs_sample.csv",index=False)dx.display("dx_docs_sample.csv")Withdx.set_display_mode()Using either"simple"or"enhanced"display modes will allowdxwill update the currentIPythondisplay formatters to allow DEX media type visualization of pandasDataFrameobjects for an entire notebook / kernel session instead of the defaultDataFramedisplay output.DetailsThis will adjust pandas options to:increasing the number of rows displayed to50000from pandas default of60increasing the number of columns displayed to50from pandas default of20enablinghtml.table_schema(Falseby default in pandas)This will also handle some basic column cleaning and generate a schema for theDataFrameusingpandas.io.json.build_table_schema. Depending on the display mode, the data will be transformed into either a list of dictionaries or list of lists of columnar values."simple"- list of dictionaries"enhanced"- list of listsNOTE:Unlikedx.display(), thisonlyaffects pandas DataFrames (or any types set insettings.RENDERABLE_TYPES); it does not affect the display of.csv/.jsonfile data, ordict/listoutputsdx.set_display_mode("simple")importdximportnumpyasnpimportpandasaspd# enable DEX display outputs from now ondx.set_display_mode("simple")df=pd.read_csv("dx_docs_sample.csv")dfdf2=pd.DataFrame([[1,5,10,20,500],[1,2,3,np.nan,5],[0,0,0,np.nan,1]],columns=['a','b','c','d','e'])df2If, at any point, you want to go back to the default display formatting (vanilla pandas output), use the"plain"display mode. This will revert the IPython display format update to its original state and put the pandas options back to their default values.dx.set_display_mode("plain")# revert to original pandas display outputs from now ondx.set_display_mode("plain")df=pd.read_csv("dx_docs_sample.csv")dfdf2=pd.DataFrame([[1,5,10,20,500],[1,2,3,np.nan,5],[0,0,0,np.nan,1]],columns=['a','b','c','d','e'])df2Custom SettingsDefault settings fordxcan be found by callingdx.settings:Each can be set usingdx.set_option():SettingDISPLAY_MAX_ROWSto3for the current session...or with thedx.settings_context()context manager:SettingDISPLAY_MAX_ROWSto3within the current context, leaving options for the rest of the session aloneGenerating Sample DataDocumentation coming soon!Usage Outside of NoteableIf using this package in a notebook environment outside ofNoteable, the frontend should support the following media types:application/vnd.dataresource+jsonfor"simple"display modeapplication/vnd.dex.v1+jsonfor"enhanced"display modeContributingSeeCONTRIBUTING.md.Code of ConductWe follow the noteable.iocode of conduct.LICENSESeeLICENSE.md.Open sourced with ❤️ byNoteablefor the community.