Skip to content
Snippets Groups Projects
Commit 1f6897f3 authored by Wade Fagen-Ulmschneider (waf)'s avatar Wade Fagen-Ulmschneider (waf)
Browse files

project_final pandas

parent ddb5b38f
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
import pandas as pd
import numpy as np
```
%% Cell type:markdown id: tags:
### Read GPA Data from CSV
Read in the GPA dataset and add a column "Course" that contains the full course number (eg: "STAT 400")
%% Cell type:code id: tags:
``` python
fa2016 = pd.read_csv("../res/gpa_fa2016.csv", dtype={"Course Number": object})
fa2016["Course"] = fa2016["Course Subject"] + " " + fa2016["Course Number"]
fa2016
```
%% Cell type:markdown id: tags:
### Group GPA Data by Course + Instructor
Group all of the data by the same instructor teaching the same course, allowing us to compare different instructors in the same course
%% Cell type:code id: tags:
``` python
fa2016_group = fa2016.groupby(["Course", "Primary Instructor"])
fa2016_prof = fa2016_group.agg({
"A+": np.sum,
"A": np.sum,
"F": np.sum,
"Average Grade": np.average
})
fa2016_prof
```
%% Cell type:markdown id: tags:
### Analysis
Explore various courses, see if what we have makes sense. We want to ensure our data is correct before we continue going further.
%% Cell type:code id: tags:
``` python
fa2016_prof = fa2016_prof.reset_index()
```
%% Cell type:code id: tags:
``` python
fa2016_prof[ fa2016_prof["Course"] == "STAT 400" ]
```
%% Cell type:markdown id: tags:
### Write to Output
Save our primary DataFrame into a CSV for work with in JavaScript / d3.js
%% Cell type:code id: tags:
``` python
fa2016_prof.to_csv("../res/profs.csv")
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
import pandas as pd
import numpy as np
```
%% Cell type:markdown id: tags:
### Read GPA Data from CSV
Read in the GPA dataset and add a column "Course" that contains the full course number (eg: "STAT 400")
%% Cell type:code id: tags:
``` python
fa2016 = pd.read_csv("../res/gpa_fa2016.csv", dtype={"Course Number": object})
fa2016["Course"] = fa2016["Course Subject"] + " " + fa2016["Course Number"]
fa2016
```
%% Cell type:markdown id: tags:
### Group GPA Data by Course + Instructor
Group all of the data by the same instructor teaching the same course, allowing us to compare different instructors in the same course
%% Cell type:code id: tags:
``` python
fa2016_group = fa2016.groupby(["Course", "Primary Instructor"])
fa2016_prof = fa2016_group.agg({
"A+": np.sum,
"A": np.sum,
"F": np.sum,
"Average Grade": np.average
})
fa2016_prof
```
%% Cell type:markdown id: tags:
### Analysis
Explore various courses, see if what we have makes sense. We want to ensure our data is correct before we continue going further.
%% Cell type:code id: tags:
``` python
fa2016_prof = fa2016_prof.reset_index()
```
%% Cell type:code id: tags:
``` python
fa2016_prof[ fa2016_prof["Course"] == "STAT 400" ]
```
%% Cell type:markdown id: tags:
### Write to Output
Save our primary DataFrame into a CSV for work with in JavaScript / d3.js
%% Cell type:code id: tags:
``` python
fa2016_prof.to_csv("../res/profs.csv")
```
%% Cell type:code id: tags:
``` python
```
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment