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.
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 = 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
| X0 | X1 | X2 |
| 0 | 0.6082017 | -1.266173 | -0.4382656 |
| 1 | 1.205478 | -2.181385 | 0.3500421 |
| 2 | -0.355007 | 1.437249 | 0.810668 |
| 3 | 0.793156 | -0.4705256 | 0.2610179 |
| 4 | -2.290062 | -1.282885 | -1.311781 |
| 5 | -0.09078383 | 0.9957932 | -0.1394528 |
| 6 | -0.5602056 | 0.4454897 | 0.322925 |
| 7 | 0.4457853 | -1.038077 | -0.8567123 |
| 8 | 0.4736169 | -0.1254977 | 0.3514178 |
| 9 | 1.782359 | 0.07020736 | -0.7813665 |
Total running time of the script: ( 0 minutes 0.173 seconds)
Gallery generated by Sphinx-Gallery