Skip to content

Instantly share code, notes, and snippets.

View exp0nge's full-sized avatar
👨‍💻
selective compiling...

MD Islam exp0nge

👨‍💻
selective compiling...
View GitHub Profile
<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">
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'))
@exp0nge
exp0nge / step-2.js
Last active May 26, 2016 02:50
step-2
$(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
@exp0nge
exp0nge / ajax.js
Last active August 29, 2015 14:26
$.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);
if form.is_valid():
poll = form.save(commit=False)
poll.submitted_user = request.user
poll.save()