Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix code blocks in user-guide/concepts/data-structures #14146

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions docs/user-guide/concepts/data-structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ The core base data structures provided by Polars are `Series` and `DataFrame`.
Series are a 1-dimensional data structure. Within a series all elements have the same [Data Type](data-types/overview.md) .
The snippet below shows how to create a simple named `Series` object.

{{code_block('getting-started/series-dataframes','series',['Series'])}}
{{code_block('user-guide/basics/series-dataframes','series',['Series'])}}

```python exec="on" result="text" session="getting-started/series"
```python exec="on" result="text" session="user-guide/data-structures"
--8<-- "python/user-guide/basics/series-dataframes.py:series"
```

## DataFrame

A `DataFrame` is a 2-dimensional data structure that is backed by a `Series`, and it can be seen as an abstraction of a collection (e.g. list) of `Series`. Operations that can be executed on a `DataFrame` are very similar to what is done in a `SQL` like query. You can `GROUP BY`, `JOIN`, `PIVOT`, but also define custom functions.

{{code_block('getting-started/series-dataframes','dataframe',['DataFrame'])}}
{{code_block('user-guide/basics/series-dataframes','dataframe',['DataFrame'])}}

```python exec="on" result="text" session="getting-started/series"
```python exec="on" result="text" session="user-guide/data-structures"
--8<-- "python/user-guide/basics/series-dataframes.py:dataframe"
```

Expand All @@ -31,38 +31,38 @@ This part focuses on viewing data in a `DataFrame`. We will use the `DataFrame`

The `head` function shows by default the first 5 rows of a `DataFrame`. You can specify the number of rows you want to see (e.g. `df.head(10)`).

{{code_block('getting-started/series-dataframes','head',['head'])}}
{{code_block('user-guide/basics/series-dataframes','head',['head'])}}

```python exec="on" result="text" session="getting-started/series"
```python exec="on" result="text" session="user-guide/data-structures"
--8<-- "python/user-guide/basics/series-dataframes.py:head"
```

#### Tail

The `tail` function shows the last 5 rows of a `DataFrame`. You can also specify the number of rows you want to see, similar to `head`.

{{code_block('getting-started/series-dataframes','tail',['tail'])}}
{{code_block('user-guide/basics/series-dataframes','tail',['tail'])}}

```python exec="on" result="text" session="getting-started/series"
```python exec="on" result="text" session="user-guide/data-structures"
--8<-- "python/user-guide/basics/series-dataframes.py:tail"
```

#### Sample

If you want to get an impression of the data of your `DataFrame`, you can also use `sample`. With `sample` you get an _n_ number of random rows from the `DataFrame`.

{{code_block('getting-started/series-dataframes','sample',['sample'])}}
{{code_block('user-guide/basics/series-dataframes','sample',['sample'])}}

```python exec="on" result="text" session="getting-started/series"
```python exec="on" result="text" session="user-guide/data-structures"
--8<-- "python/user-guide/basics/series-dataframes.py:sample"
```

#### Describe

`Describe` returns summary statistics of your `DataFrame`. It will provide several quick statistics if possible.

{{code_block('getting-started/series-dataframes','describe',['describe'])}}
{{code_block('user-guide/basics/series-dataframes','describe',['describe'])}}

```python exec="on" result="text" session="getting-started/series"
```python exec="on" result="text" session="user-guide/data-structures"
--8<-- "python/user-guide/basics/series-dataframes.py:describe"
```
Loading