Skip to content

Commit

Permalink
Added more to the export chapter for #81
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire committed Feb 18, 2023
1 parent 7d11989 commit a7bbd4e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/src/export.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ merged_list['per_100k_hours'] = (merged_list.accidents / merged_list.total_hours
merged_list.to_csv("accident-rate-ranking.csv")
```

The `to_csv()` method takes several optional arguments, but the most important one is the filename argument, which is used to specify the path and name of the CSV file to be created. The `index=False` keyword argument tells pandas to exclude the index column of the DataFrame. You can also specify the separator by passing the `sep` parameter.
The file it creates can be imported into other program for reuse, including the data visualization programs many newsrooms rely on to publish graphics. For instance, the file we've exported above could be used to quickly draft a chart with Datawrapper, like this one:

<iframe title="Helicopter accident rates" aria-label="Split Bars" id="datawrapper-chart-6gTy3" src="https://datawrapper.dwcdn.net/6gTy3/1/" scrolling="no" frameborder="0" style="width: 0; min-width: 100% !important; border: none;" height="452" data-external="1"></iframe><script type="text/javascript">!function(){"use strict";window.addEventListener("message",(function(e){if(void 0!==e.data["datawrapper-height"]){var t=document.querySelectorAll("iframe");for(var a in e.data["datawrapper-height"])for(var r=0;r<t.length;r++){if(t[r].contentWindow===e.source)t[r].style.height=e.data["datawrapper-height"][a]+"px"}}}))}();
</script>

```{note}
Interesting in learning more about how to publish data online? Check out ["First Visual Story,"](https://palewi.re/docs/first-visual-story/) a tutorial that will show you how journalists at America’s top news organizations escape rigid content-management systems to publish custom interactive graphics on deadline.
```


The `to_csv()` method accepts several additional optional arguments. The most important one is the filename input, which is used to specify the path and name of the file that will be created. The `index=False` keyword argument tells pandas to exclude the index column of the DataFrame. You can also specify the separator by passing the `sep` parameter.


```{code-cell}
Expand Down

0 comments on commit a7bbd4e

Please sign in to comment.