This quick tutorial shows how to extract pandas DataFrames from D-Tale for continued analysis. For a complete introduction to D-Tale’s interactive features, see our D-Tale: Visual Analytics for Pandas DataFrames guide.
The Problem
After exploring data visually in D-Tale, you often need to return to pandas for statistical analysis, machine learning pipelines, or automated reporting. D-Tale excels at interactive exploration, but eventually you need the underlying DataFrame back in your Python environment. Without a clear way to extract the data, you’d be stuck copying values manually or reloading from the original source.
The Solution
The D-Tale instance stores your DataFrame in the data attribute. Access it directly to retrieve your pandas DataFrame for continued work.
import dtale
import seaborn as sns
df = sns.load_dataset('planets') # Exoplanet data
d = dtale.show(df, open_browser=True) # Load your DataFrame
d_to_pandas = d.data
# Continue with pandas operations
print(d_to_pandas.head())
Output:
method number orbital_period mass distance year 0 Radial Velocity 1 269.300 7.10 77.40 2006 1 Radial Velocity 1 874.774 2.21 56.95 2008 2 Radial Velocity 1 763.000 2.60 19.84 2011 3 Radial Velocity 1 326.030 19.40 110.62 2007 4 Radial Velocity 1 516.220 10.50 119.47 2009
The d.data attribute returns the complete DataFrame exactly as it exists in D-Tale at that moment. Any filters, sorts, or transformations you applied through the D-Tale interface persist in the extracted DataFrame. This means you can explore data visually, identify patterns, filter to interesting subsets, and then extract just those filtered results for further analysis.
Once extracted, the DataFrame works like any other pandas object. Run statistical functions, merge with other datasets, feed it into machine learning models, or save it to files. The extracted DataFrame maintains all column types, indexes, and data integrity from your D-Tale session.
A Few Tips
The extracted DataFrame reflects D-Tale’s current state, but changes you make to the extracted DataFrame won’t affect the D-Tale session. They’re separate objects after extraction. If you modify data in pandas and want to see those changes in D-Tale, create a new D-Tale instance with the updated DataFrame.
This extraction pattern works well when you use D-Tale for initial exploration and pandas for deeper analysis. Explore visually to understand distributions and spot outliers, then extract the data to calculate correlations, fit models, or generate automated reports.
Conclusion
Extracting DataFrames from D-Tale gives you the flexibility to switch between visual exploration and programmatic analysis. The data attribute makes the transition seamless.
