.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_data_analysis/manage_data_and_samples/plot_sample_pandas.py" .. LINE NUMBERS ARE GIVEN BELOW. .. 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 ========================= .. GENERATED FROM PYTHON SOURCE LINES 5-7 .. code-block:: default # sphinx_gallery_thumbnail_path = '_static/pandas.png' .. GENERATED FROM PYTHON SOURCE LINES 8-9 In this example we are going to explore interaction with Pandas data analysis tool. .. GENERATED FROM PYTHON SOURCE LINES 11-16 .. code-block:: default from __future__ import print_function import openturns as ot import pandas as pd ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 17-18 Create a sample from a 3-d normal distribution .. GENERATED FROM PYTHON SOURCE LINES 18-20 .. code-block:: default sample = ot.Normal(3).getSample(10) .. GENERATED FROM PYTHON SOURCE LINES 21-22 Create a DataFrame from a Sample .. GENERATED FROM PYTHON SOURCE LINES 22-25 .. 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.330767 0.078262 0.028626
std 1.068377 0.927432 0.924196
min -0.721533 -1.488986 -1.787964
25% -0.488980 -0.304870 -0.620888
50% 0.155288 -0.027645 0.337171
75% 0.466659 0.858217 0.506955
max 2.514145 1.367826 1.188010


.. GENERATED FROM PYTHON SOURCE LINES 26-27 Create a Sample from a DataFrame .. GENERATED FROM PYTHON SOURCE LINES 27-30 .. code-block:: default sample2 = ot.Sample(df.values) sample2.setDescription(df.columns) sample2 .. raw:: html
X0X1X2
0-0.4276561.1231741.18801
12.514145-1.4889860.5213786
2-0.5094218-0.3260850.4636851
3-0.090783830.9957932-0.1394528
4-0.56020560.44548970.322925
50.4457853-1.038077-0.8567123
60.4736169-0.12549770.3514178
71.7823590.07020736-0.7813665
8-0.7215334-0.2412235-1.787964
90.40135971.3678261.004343


.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.223 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 `_