Skip to content

Commit

Permalink
Merge pull request #14 from fhdsl/S4
Browse files Browse the repository at this point in the history
images
  • Loading branch information
caalo authored Aug 19, 2024
2 parents dc19a66 + 290d1cf commit 9e753c9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 02-data-structures.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,25 @@ Perhaps the most important operation you will can do with Dataframes is subsetti

You will use the `iloc` and bracket operations, and you give two slices: one for the row, and one for the column.

Let's start with a small dataframe to see how it works before returning to `metadata`:

```{python}
df = pd.DataFrame(data={'status': ["treated", "untreated", "untreated", "discharged", "treated"],
'age_case': [25, 43, 21, 65, 7],
'age_control': [49, 20, 32, 25, 32]})
df
```

Here is how the dataframe looks like with the row and column index numbers:

![](images/pandas_subset_0.png)

Subset the second to fourth rows, and the first two columns:

![](images/pandas_subset_1.png)

Now, back to `metadata` dataframe.

Subset the first 5 rows, and first two columns:

```{python}
Expand Down
9 changes: 9 additions & 0 deletions 03-data-wrangling1.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
```{r, include = FALSE}
ottrpal::set_knitr_image_path()
```

# Data Wrangling

## Exercises

Exercise for week 3 can be found [here](#)
1 change: 1 addition & 0 deletions _bookdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ repo: https://github.com/jhudsl/OTTR_Template/
rmd_files: ["index.Rmd",
"01-intro-to-computing.Rmd",
"02-data-structures.Rmd",
"03-data-wrangling1.Rmd",
"About.Rmd",
"References.Rmd"]
new_session: yes
Expand Down
Binary file added images/pandas_subset_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/pandas_subset_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9e753c9

Please sign in to comment.