Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit b71a9a8

Browse files
committed
Expand documentation in README.md
1 parent e2935ff commit b71a9a8

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ If there are several ROOT trees in the input file, you have to specify the tree
3131
df = read_root('myfile.root', 'mykey')
3232
```
3333

34+
You can also directly read multiple ROOT files at once by passing a list of file names:
35+
```python
36+
df = read_root(['file1.root', 'file2.root', 'mykey'])
37+
```
38+
In this case, each file must have the same set of columns under the given key.
39+
3440
Specific columns can be selected like this:
3541
```python
3642
df = read_root('myfile.root', columns=['variable1', 'variable2'])
@@ -45,9 +51,14 @@ In addition, you can use shell brace patterns as in
4551
```python
4652
df = read_root('myfile.root', columns=['variable{1,2}'])
4753
```
48-
4954
You can also use `*` and `{a,b}` simultaneously, and several times per string.
5055

56+
If you want to transform your variables using a ROOT selection string, you have
57+
to put a `noexpand:` prefix in front of the column name that you want to use the selection string in:
58+
```python
59+
df = read_root('myfile.root', columns=['noexpand:sqrt(variable1)']
60+
```
61+
5162
Working with stored arrays can be a bit inconventient in pandas.
5263
`root_pandas` makes it easy to flatten your input data, providing you with a DataFrame containing only scalars:
5364
```python
@@ -84,6 +95,14 @@ By default, `to_root` erases the existing contents of the file. Use `mode='a'` t
8495
for df in read_root('bigfile.root', chunksize=100000):
8596
df.to_root('out.root', mode='a')
8697
```
87-
When doing this to stream data from one ROOT file into another, you shouldn't forget to `os.remove` the output file first, otherwise you will append more and more data to it on each run of your program.
98+
**Warning:** When using this feature to stream data from one ROOT file into
99+
another, you shouldn't forget to `os.remove` the output file first, otherwise
100+
you will append more and more data to it on each run of your program.
101+
102+
## The DataFrame index
88103

104+
When reading a ROOT file, `root_pandas` will automatically add a pandas index
105+
to the DataFrame, which starts at 1 and counts up for each entry.
106+
When writing the a DataFrame to a ROOT file, it stores the DataFrame index in a `__index__` branch.
107+
Currently, only single-dimensional indices are supported.
89108

0 commit comments

Comments
 (0)