# Fill existing tree in pyroot

**URL:** <https://root-forum.cern.ch/t/fill-existing-tree-in-pyroot/43254>\
**Category:** Newbie\
**Created:** [January 25, 2021, 11:48am UTC](https://root-forum.cern.ch/t/fill-existing-tree-in-pyroot/43254 "2021-01-25T11:48:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [January 25, 2021, 1:01pm UTC](https://root-forum.cern.ch/t/fill-existing-tree-in-pyroot/43254/2 "2021-01-25T13:01:58Z")

</div>

Hello,  
I will answer in the original thread:

> [@Filling different trees in a loop in pyroot](https://root-forum.cern.ch/t/filling-different-trees-in-a-loop-in-pyroot/43239/2):
>
> Hello, The most efficient way to do this would be to use RDataFrame: With RDataFrame, the loop would happen in C++, and therefore the performance would be better than to have it in Python. As for what you want to do, the way to proceed would be to create an RDataFrame from your initial tree stored in your ROOT file. From that tree, you can define new columns (branches) based on the information contained in the initial tree. Finally, you can Snapshot (store in a file) the derived trees. In …

---

_[View the full topic](https://root-forum.cern.ch/t/fill-existing-tree-in-pyroot/43254)._
