Giter Site home page Giter Site logo

donation-analytics's Introduction

donation-analytics

For solving the challenge Donation-Analytics, I took advantage of the input files provided by the example (incont.txt) in the description of the challenge and I also used data downloaded from https://classic.fec.gov/finance/disclosure/ftpdet.shtml in the "Contributions by Individuals". Specifically, I used the itcont.txt files inside the indiv16.zip and indiv18.zip which correspond to data of individual contribution from the year 2015 until today's date. As the files obtained from the website are quite large, for simplicity a small dataset is found in the input file itcont.txt. The input file percentile.txt only has the value requested to preform the percentile calculation and can be changed for other percentile values calculations.

I used python to write the code, specifically pandas. When analyzing my code, please download the following dependencies:

#Dependencies import math from collections import Counter import csv import pandas as pd import numpy as np import os import time from scipy import stats from datetime import datetime import datetime as dt

The data was then cleaned using the following parameters:

-Consider only data with a date from the year 2015 until today's date since we know that the input file follows the data dictionary noted by the FEC for the 2015-current election years (https://classic.fec.gov/finance/disclosure/metadata/DataDictionaryContributionsbyIndividuals.shtml). In this same site, we can find the header with the corresponding labels for the data obtained and in this way, we can further analyze specific fields;

  • As instructed, only the fields 'CMTE_ID', 'NAME', ZIP_CODE', 'TRANSACTION_DT', 'TRANSACTION_AMT', 'OTHER_ID' were selected;

-Empty or null entries were removed with the exception of 'OTHER_ID' entries where all should be NAN;

-The data was further cleaned by making sure that the above fields meet the FEC dictionary specifications in terms of length and data type;

-'ZIP_CODE' is represented by its first five characters and 'TRANSACTION_DT' is expressed by the year of transaction;

-Repeated donors were found by using both 'NAME', and ZIP_CODE' combined for data selection;

-According to the instructions, entries that are not chronologically ordered should be sorted out and therefore 2 condition statements were made in the code in order to select only chronologically ordered data from repeated donors;

-Having the data cleaned, the calculations required in the challenge were made and are presented in the code;

-This code is written to be able to deal both with streaming (chronologically in and out of order) data and also to analyze a data at a specific time point from 2015 until today's date. The value of the percentile required can also be adjusted accordingly to the number provided by the percentile.txt file;

-The Output is printed in a .txt file;

donation-analytics's People

Contributors

salomebot avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.