Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions SCF_plus/SCF_plus_mini_no_weights.csv
Git LFS file not shown
29 changes: 26 additions & 3 deletions SCF_plus/generating_mini.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ kernelspec:
name: python3
---



Regarding converting between ``.ipynb`` and ``.md`` please refer to https://manual.quantecon.org/writing/converting.html

```{code-cell} ipython3
Expand Down Expand Up @@ -49,8 +47,33 @@ df1.columns = var_names_new
df1
```

Export the dataset with weights.

```{code-cell} ipython3
# df1.to_csv('SCF_plus_mini.csv', index=None) # use it when you want to export the weighted data
```

Generate and export the dataset without weights.

```{code-cell} ipython3
counts = list(round(df1['weights']))
df1["weights"] = counts
```

```{code-cell} ipython3
df2 = df1.loc[df1.index.repeat(df1.weights)].reset_index(drop=True)
```

```{code-cell} ipython3
df2 = df2.drop(columns=['weights'])
```

```{code-cell} ipython3
df2
```

```{code-cell} ipython3
df1.to_csv('SCF_plus_mini.csv', index=None)
# df2.to_csv('SCF_plus_mini_no_weights.csv', index=None) # use it when you want to export the non weighted data
```

```{code-cell} ipython3
Expand Down