This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="content" style="min-height: 500px;"> | |
<div class=""> | |
<div class=""> | |
<div class="default-count"><span class="number"></span></div> | |
/30000 total defaulters | |
</div> | |
</div> | |
<div class=""> | |
<div class=""> | |
<div id="genderPie"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import json data = pd.read_csv('default of credit card clients.csv') | |
with open('data.json', 'w') as f: | |
f.write(data.reset_index().to_json(orient='records')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
d3.json('data.json', function (data) { | |
var ndx = crossfilter(data); // Tell Crossfilter what data we want to filter. | |
//defaultDim is for the total # of defaulters ticker. | |
var defaultDim = ndx.dimension(function (d) { | |
return d['default payment next month']; | |
}); | |
//genderDim filters based on gender. The function will iterate over the 30,000 records returning either Male, Female, or Unknown every time. | |
// We can then use dc.js to tally those up. | |
var genderDim = ndx.dimension(function (d) { //notice the parameter, since we told Crossfilter what our data is, we can just get it in our callbacks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
url: '/url/for/processing', | |
type: 'GET', | |
data: {csrfmiddlewaretoken: document.getElementsByName('csrfmiddlewaretoken')[0].value}, | |
dataType: 'json', | |
success: function (response) { | |
console.log('OK'); | |
}, | |
error: function (response) { | |
console.log(response); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if form.is_valid(): | |
poll = form.save(commit=False) | |
poll.submitted_user = request.user | |
poll.save() |
NewerOlder