.. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_data_analysis_manage_data_and_samples_plot_sample_pandas.py: Link Pandas and OpenTURNS ========================= .. code-block:: default # sphinx_gallery_thumbnail_path = '_static/pandas.png' In this example we are going to explore interaction with Pandas data analysis tool. .. code-block:: default from __future__ import print_function import openturns as ot import pandas as pd ot.Log.Show(ot.Log.NONE) create a sample from a 3-d gaussian distribution .. code-block:: default sample = ot.Normal(3).getSample(10) Create a DataFrame from a Sample .. code-block:: default df = pd.DataFrame.from_records(sample, columns=sample.getDescription()) df.describe() .. raw:: html
X0 X1 X2
count 10.000000 10.000000 10.000000
mean 0.201254 -0.341580 -0.143151
std 1.122471 1.126257 0.678845
min -2.290062 -2.181385 -1.311781
25% -0.288951 -1.209149 -0.695591
50% 0.459701 -0.298012 0.060783
75% 0.746917 0.351669 0.343263
max 1.782359 1.437249 0.810668


Create a Sample from a DataFrame .. code-block:: default sample2 = ot.Sample(df.values) sample2.setDescription(df.columns) sample2 .. raw:: html
X0X1X2
00.6082017-1.266173-0.4382656
11.205478-2.1813850.3500421
2-0.3550071.4372490.810668
30.793156-0.47052560.2610179
4-2.290062-1.282885-1.311781
5-0.090783830.9957932-0.1394528
6-0.56020560.44548970.322925
70.4457853-1.038077-0.8567123
80.4736169-0.12549770.3514178
91.7823590.07020736-0.7813665


.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.156 seconds) .. _sphx_glr_download_auto_data_analysis_manage_data_and_samples_plot_sample_pandas.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_sample_pandas.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_sample_pandas.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_