Skip to content

Commit

Permalink
Merge branch 'dev' into fix_class_instantiations
Browse files Browse the repository at this point in the history
  • Loading branch information
gviejo authored Dec 13, 2024
2 parents 9758aab + 17faa1e commit b120f1e
Show file tree
Hide file tree
Showing 56 changed files with 389 additions and 5,048 deletions.
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pynapple: python neural analysis package

.. grid-item-card:: Time Series
:text-align: center
:link: ./user_guide/04_core_methods.html
:link: ./user_guide/03_core_methods.html

.. image:: _static/example_thumbs/timeseries.svg
:class: dark-light
Expand Down
6 changes: 5 additions & 1 deletion doc/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ Interaction with numpy <user_guide/03_interacting_with_numpy>
```

```{toctree}
Core methods <user_guide/04_core_methods>
Core methods <user_guide/03_core_methods>
```

```{toctree}
Metadata <user_guide/03_metadata>
```
:::

Expand Down
28 changes: 28 additions & 0 deletions doc/user_guide/01_introduction_to_pynapple.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ Slicing objects

### Slicing time series and intervals

#### Like numpy array

`Ts`, `Tsd`, `TsdFrame`, `TsdTensor` and `IntervalSet` can be sliced similar to numpy array:

```{code-cell} ipython3
Expand Down Expand Up @@ -271,6 +273,32 @@ print(ep[0:2])
print(ep[1])
```

#### Like pandas DataFrame

:::{important}
This [page](03_core_methods.md#special-slicing-tsdframe) references all the way to slice `TsdFrame`
:::


`TsdFrame` can be sliced like pandas DataFrame when the columns have been labelled with strings :

```{code-cell} ipython3
tsdframe = nap.TsdFrame(t=np.arange(10), d=np.random.randn(10,3), columns=['a', 'b', 'c'])
print(tsdframe['a'])
```
but integer-indexing only works like numpy if a list of integers is used to label columns :

```{code-cell} ipython3
tsdframe = nap.TsdFrame(t=np.arange(4), d=np.random.randn(4,3), columns=[3, 2, 1])
print(tsdframe, "\n")
print(tsdframe[3])
```

The `loc` method can be used to slice column-based only :

```
print(tsdframe.loc[3])
```

### Slicing TsGroup

Expand Down
Loading

0 comments on commit b120f1e

Please sign in to comment.