# Plot of nested beans

**URL:** <https://root-forum.cern.ch/t/plot-of-nested-beans/35951>\
**Category:** ROOT\
**Tags:** rdataframe\
**Created:** [September 10, 2019, 1:21am UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951 "2019-09-10T01:21:41Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marsupilami](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/marsupilami/32/17168_2.png) [@Marsupilami](https://root-forum.cern.ch/u/Marsupilami)\
**Post date:** [September 10, 2019, 1:21am UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/1 "2019-09-10T01:21:42Z")

</div>

Hi,  
I am trying to plot what we call VMEC cuts with the method ROOT::RDF::RCsvDS method but unfortunately I get a lot of errors (including segmentation faults) and I cannot picture why. Are the graphs not allowed to close on themselves?

Attached you’ll find corresponding data.[cross\_vmec\_beta485\_ref\_bean.txt](https://root-forum.cern.ch/uploads/short-url/p1sbGASmqhZ22ngva8R5JXYMpYK.txt) (16.5 KB) [VMEC\_CUT.c](https://root-forum.cern.ch/uploads/short-url/4ZCclfjFU4K5tHCf9LRBPJj5wGx.c) (2.4 KB)

* * *

_ROOT Version:_ 6.14  
_Platform:_ Ubuntu  
_Compiler:_ Clang

* * *

---

<div class="post-metadata">

**Author:** ![Marsupilami](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/marsupilami/32/17168_2.png) [@Marsupilami](https://root-forum.cern.ch/u/Marsupilami)\
**Post date:** [September 11, 2019, 3:49pm UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/2 "2019-09-11T15:49:00Z")

</div>

Usually these Error arises when the first line of the File does not exist of floating points with a single space in between. But unfortunately this is not the case, so I sadly have no clue what the problem could be.

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [September 12, 2019, 8:48am UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/3 "2019-09-12T08:48:54Z")

</div>

Hi,  
sorry I started looking at this yesterday but forgot to reply.  
It looks like a problem with the parsing in RCsvDS, but it will require a bit more time to figure out.

We will report back as soon as possible.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [September 12, 2019, 9:32am UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/4 "2019-09-12T09:32:37Z")

</div>

Hi again,  
here’s the problem:

```auto
~/Downloads root -l (tvem) 
root [0] a = ROOT::RDF::MakeCsvDataFrame("cross_vmec_beta485_ref_bean.txt", false, ' ')
(ROOT::RDataFrame &) A data frame associated to the data source "CSV data source"
root [1] a.GetColumnType("Col0")
(std::string) "double"
root [2] a.GetColumnType("Col1")
(std::string) "std::string"

```

RCsvDS thinks your second column is a `std::string` – I don’t know why this happens (yet), but this is a bug, so I opened [https://sft.its.cern.ch/jira/browse/ROOT-10313](https://sft.its.cern.ch/jira/browse/ROOT-10313) to track it.

Please ping us if you don’t hear back from us in a few days.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![Marsupilami](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/marsupilami/32/17168_2.png) [@Marsupilami](https://root-forum.cern.ch/u/Marsupilami)\
**Post date:** [September 17, 2019, 10:11pm UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/5 "2019-09-17T22:11:10Z")

</div>

Thank you very much Enrico for your effort. It seems like nobody answered yet on the bug. Is there a way around it?

Best  
Jim

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [September 18, 2019, 6:42am UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/6 "2019-09-18T06:42:16Z")

</div>

Hi Jim, this should get fixed “soon-ish” - @etejedor might be able to share his estimate?

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [September 18, 2019, 7:24am UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/7 "2019-09-18T07:24:12Z")

</div>

Dear Jim,  
I will try to find some time next week to have a look. Apologies for the wait.  
Enric

---

<div class="post-metadata">

**Author:** ![Marsupilami](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/marsupilami/32/17168_2.png) [@Marsupilami](https://root-forum.cern.ch/u/Marsupilami)\
**Post date:** [September 18, 2019, 5:19pm UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/8 "2019-09-18T17:19:58Z")

</div>

Hi Everybody,

sadly I have a time problem attached to the plotting problem. The referees want to have the correction of my paper not later then the 25th of September. Is it possible to fix the bug until a day before or maybe supply myself with an alternative solution?

Kind Regards  
Jim

---

<div class="post-metadata">

**Author:** ![Marsupilami](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/marsupilami/32/17168_2.png) [@Marsupilami](https://root-forum.cern.ch/u/Marsupilami)\
**Post date:** [September 18, 2019, 8:49pm UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/9 "2019-09-18T20:49:46Z")

</div>

Just to be sure. This Problem is the same bug isn’t it?  
[POINCARE.c](https://root-forum.cern.ch/uploads/short-url/1RSLH37Acb0F0PgcexSaqVxVyT.c) (1.4 KB) [Points\_Stoch.txt](https://root-forum.cern.ch/uploads/short-url/tPEZdin2gBiDCo5Yd8pkVtz8BDQ.txt) (877.9 KB)

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [September 19, 2019, 8:43am UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/10 "2019-09-19T08:43:09Z")

</div>

Hi Jim,

I had a quick look, my guess is that your second column is not being parsed as a double because it has values with this exponential syntax: -7.6076468e-16, which is perfectly fine, it is just not supported by the current implementation. I will add support for it when I have some time.

In the meantime, what you can do as a workaround is have an extra `Define` in your RDataFrame chain that transforms your string column into a double column.That `Define` should receive a lambda function that accepts an std::string as parameter, transforms it into a double and returns that double.

---

<div class="post-metadata">

**Author:** ![Marsupilami](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/marsupilami/32/17168_2.png) [@Marsupilami](https://root-forum.cern.ch/u/Marsupilami)\
**Post date:** [September 20, 2019, 12:51am UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/11 "2019-09-20T00:51:14Z")

</div>

Hi etejedor,

sadly this is not true. I deleted the lines, which included a number of the form e-16 but the segmentation fault is still present. Check for yourself  
[cross\_vmec\_beta485\_ref\_bean.txt](https://root-forum.cern.ch/uploads/short-url/nfMWNpRr7R3G7xys6kAxwdkxcsp.txt) (14.8 KB)

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [September 20, 2019, 9:36am UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/12 "2019-09-20T09:36:45Z")

</div>

Hi,  
as an attempt to unblock you as long as the bug is there, here’s an implementation of Enric’s suggestion:

```cpp
auto df = ROOT::RDF::MakeCsvDataFrame("cross_vmec_beta485_ref_bean.txt", false, ' ')
auto df2 = df.Define("Col1Double", "stof(Col1)")

```

where `stof` converts Col1 (wrongly read in as a `std::string`) to a float column called `Col1Double` that you can use to fill histos.

Hope this helps!  
Enrico

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [September 20, 2019, 4:23pm UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/13 "2019-09-20T16:23:53Z")

</div>

Hi,

The issue is that the .txt file was generated in Windows. When reading from the file in Linux, `std::getline` returns a string ended in `\r`. That `\r` is parsed as part of the second column, and therefore the inferred type is string. You can convert your Windows file to unix format with e.g. `dos2unix`.

Also, I noticed that the first row contains a `0` in the second column. Provided that you convert the file to unix format, and since it is the first row that is used to infer the types, the second column will be inferred as an integer. You can change that just by changing that value to `0.` to force the infererred type to be double.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [October 4, 2019, 4:23pm UTC](https://root-forum.cern.ch/t/plot-of-nested-beans/35951/14 "2019-10-04T16:23:58Z")

</div>

Closed on October 4, 2019, 4:23pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
