Giter VIP home page Giter VIP logo

untreaties's Introduction

This repository contains a set of scripts that allow the retrieval of the United Nations' Treaty Collection, and transformation of the retrieved data. Please open an issue if you find any errors or would like to suggest a feature. Pull requests are welcome!

Getting the data

You can clone (see below) or download the data contained in this repository or scrape it using un_data.py, which requires pandas, requests, and beautifulsoup4. These dependencies are listed in requirements.txt. The script will generate index.csv along with a folder containing the treaty data itself (treaties) and a folder containing declarations made by participants (contained in declarations).

git clone [email protected]:zmjones/untreaties.git
cd untreaties
pip install -r requirements.txt
python un_data.py

Transforming the data

The R script utilities.R contains a number of functions that make working with the raw data easier. You can load these functions by simply sourcing the file. It requires stringr, lubridate, and plyr. The loadData function allows the user to load a specific treaty given its chapter and treaty numbers, which are passed as strings. You can optionally expand the column names (if needed). If you choose to expand the column names you can also transform the data into a country-year format, given a start year and an end year (both passed as strings).

source("utilities.R")
loadData(chap = "10", treaty = "2")
loadData(chap = "10", treaty = "2", expand = TRUE)
loadData(chap = "10", treaty = "2", expand = TRUE, panel = TRUE, syear = "1945", eyear = "2013")

untreaties's People

Contributors

zmjones avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

untreaties's Issues

column expander switches entries

Via Daniel HIll:

cedaw.dat<-loadData(chap="4", treaty="8", expand=T, panel=T, syear="1979", eyear="2012")

to produce ratification dates for CEDAW, I get some bad dates. The .csv files in the "treaties" folder look correct, but the data frame the function produces is bad. For the first 12 countries I get a mix of good and bad dates.

afghanistan is fine

96 for albania (should be 94)
97 for algeria (should be 96)
86 for andorra (should be 97)
89 for angola (should be 86)
93 for antigua (should be 89)

argentina is fine
armenia fine
australia fine
austria is fine

96 for azerbaijan (should be 95)
06 for bahamas (should be 93)

xml reading fails

scraper is currently broken. treaties.un.org changed the xml links.

expansion bug(s)

Sorry to report I've found another snag w/ the treaty utility. It's still producing some errors. Mostly this is happening for treaties that have options for the second column besides accession, ratification, and succession. These other options include acceptance (A), approval (AA), and formal confirmation (c). E.g., the air pollution treaty (chapter 27, treaty 1), ozone treaty (treaty 2) and climate change convention (treaty 7), conventions on conventional and chemical weapons (chapter 26, treaties 2 and 3) and landmines (treaty 5). I also noticed one which had no other options for the second column but was switching accession and succession; the convention on consent to marriage (chapter 16, treaty 3).

via Danny Hill

Consider contributing to Wikidata?

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.