• Home
  • Get it
  • Doc
  • Forum
  • Chat
  • Modules
  • Code
  • Bugs

OpenTURNS

An Open source initiative for the Treatment of Uncertainties, Risks'N Statistics

Navigation

  • index
  • next |
  • previous |
  • OpenTURNS 1.18rc1 documentation »
  • Contents »
  • Examples »
  • Data analysis »
  • Link Pandas and OpenTURNS

Previous topic

Randomize the lines of a Sample

Next topic

Import / export a sample via a CSV file

This Page

  • Show Source

Quick search

Note

Click here to download the full example code

Link Pandas and OpenTURNSΒΆ

# sphinx_gallery_thumbnail_path = '_static/pandas.png'

In this example we are going to explore interaction with Pandas data analysis tool.

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 normal distribution

sample = ot.Normal(3).getSample(10)

Create a DataFrame from a Sample

df = pd.DataFrame.from_records(sample, columns=sample.getDescription())
df.describe()
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


Create a Sample from a DataFrame

sample2 = ot.Sample(df.values)
sample2.setDescription(df.columns)
sample2
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


Total running time of the script: ( 0 minutes 0.223 seconds)

Download Python source code: plot_sample_pandas.py

Download Jupyter notebook: plot_sample_pandas.ipynb

Gallery generated by Sphinx-Gallery

Navigation

  • index
  • next |
  • previous |
  • OpenTURNS 1.18rc1 documentation »
  • Contents »
  • Examples »
  • Data analysis »
  • Link Pandas and OpenTURNS
© Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca. Last updated on Nov 08, 2021. Created using Sphinx 4.2.0.