• 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.21.3 documentation »
  • Contents »
  • Examples »
  • Data analysis »
  • Manage data and samples »
  • Link Pandas and OpenTURNS

Previous topic

Manage data and samples

Next topic

Randomize the lines of a Sample

This Page

  • Show Source

Quick search

Note

Go to the end 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.

import openturns as ot

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 = sample.asDataFrame()
df.describe()
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

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


Download Jupyter notebook: plot_sample_pandas.ipynb

Download Python source code: plot_sample_pandas.py

Navigation

  • index
  • next |
  • previous |
  • OpenTURNS 1.21.3 documentation »
  • Contents »
  • Examples »
  • Data analysis »
  • Manage data and samples »
  • Link Pandas and OpenTURNS
© Copyright 2005-2023 Airbus-EDF-IMACS-ONERA-Phimeca. Last updated on Dec 04, 2023. Created using Sphinx 5.3.0.