Skip to content

Commit

Permalink
initial version after pydata warsaw 2017
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexS12 committed Oct 24, 2017
1 parent 5f531d8 commit c995ba8
Show file tree
Hide file tree
Showing 12 changed files with 1,447 additions and 0 deletions.
269 changes: 269 additions & 0 deletions data/API_IS.AIR.DPRT_DS2_en_csv_v2/API_IS.AIR.DPRT_DS2_en_csv_v2.csv

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"INDICATOR_CODE","INDICATOR_NAME","SOURCE_NOTE","SOURCE_ORGANIZATION",
"IS.AIR.DPRT","Air transport, registered carrier departures worldwide","Registered carrier departures worldwide are domestic takeoffs and takeoffs abroad of air carriers registered in the country.","International Civil Aviation Organization, Civil Aviation Statistics of the World and ICAO staff estimates.",
7 changes: 7 additions & 0 deletions data/annual_passengers_carried_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Series Name,Series Code,Country Name,Country Code,1960 [YR1960],1961 [YR1961],1962 [YR1962],1963 [YR1963],1964 [YR1964],1965 [YR1965],1966 [YR1966],1967 [YR1967],1968 [YR1968],1969 [YR1969],1970 [YR1970],1971 [YR1971],1972 [YR1972],1973 [YR1973],1974 [YR1974],1975 [YR1975],1976 [YR1976],1977 [YR1977],1978 [YR1978],1979 [YR1979],1980 [YR1980],1981 [YR1981],1982 [YR1982],1983 [YR1983],1984 [YR1984],1985 [YR1985],1986 [YR1986],1987 [YR1987],1988 [YR1988],1989 [YR1989],1990 [YR1990],1991 [YR1991],1992 [YR1992],1993 [YR1993],1994 [YR1994],1995 [YR1995],1996 [YR1996],1997 [YR1997],1998 [YR1998],1999 [YR1999],2000 [YR2000],2001 [YR2001],2002 [YR2002],2003 [YR2003],2004 [YR2004],2005 [YR2005],2006 [YR2006],2007 [YR2007],2008 [YR2008],2009 [YR2009],2010 [YR2010],2011 [YR2011],2012 [YR2012],2013 [YR2013],2014 [YR2014],2015 [YR2015]
"Air transport, passengers carried",IS.AIR.PSGR,World,WLD,..,..,..,..,..,..,..,..,..,..,310441392,331604904,..,401571800,421145200,432276500,471773396,513269292,576090004,648400600,641872888,640619400,654482108,685101596,732410288,783198104,842594296,904838104,953896012,983208800,1024976616,1133228204,1145436692,1142265216,1233233404,1302891640.1,1390963704,1455104192,1466961780,1562256300,1674064712,1655230214,1627404873,1665309283,1888695284,1970142144,2072995909,2209136496,2208218737,2249518122,2628231062.6889,2786918945.85518,2894035636.71704,3050796410.97472,3213664822.0802,..
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Data from database: World Development Indicators,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Last Updated: 02/17/2016,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
11 changes: 11 additions & 0 deletions data/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Getting the data

As the database is too big to be uploaded to the repository it is stored separately [here](https://www.dropbox.com/s/n9inalri0dvff1j/avall.db?dl=1). It can be placed in the `data` folder manually or downloaded using the `get_data.py` python script.

The data can also be obtained directly from NTSB website (https://app.ntsb.gov/avdata/) in `mdb` format. In order to convert it to a SQLite database the script `export_access2csv.sh` in `utils` folder can be used:

```
$ bash utils/export_access2csv.sh data/raw/avall.mdb data
```

* avall.db -> NTSB aviation data from the new NTSB accident database system (eADMS)
4 changes: 4 additions & 0 deletions flight_safety/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import pandas as pd

pd.set_option('max_columns', 100)
pd.set_option('max_rows', 100)
38 changes: 38 additions & 0 deletions flight_safety/get_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import urllib.request
import os
from tqdm import tqdm


def download_data(url, destination_folder="../data", name='avall.db', force=False):

path = os.path.join(destination_folder, name)

if not os.path.isfile(path) or force:
print('Downloading...')
with TqdmUpTo(unit='B', unit_scale=True, miniters=1) as t:
urllib.request.urlretrieve(url, path, reporthook=t.update_to)
else:
print("Data has already been downloaded")


class TqdmUpTo(tqdm):
"""Provides `update_to(n)` which uses `tqdm.update(delta_n)`."""
def update_to(self, b=1, bsize=1, tsize=None):
"""
b : int, optional
Number of blocks transferred so far [default: 1].
bsize : int, optional
Size of each block (in tqdm units) [default: 1].
tsize : int, optional
Total size (in tqdm units). If [default: None] remains unchanged.
"""
if tsize is not None:
self.total = tsize
self.update(b * bsize - self.n) # will also set self.n = b * bsize



if __name__ == '__main__':

URL = "https://www.dropbox.com/s/n9inalri0dvff1j/avall.db?dl=1"
download_data(URL, force=True)
Loading

0 comments on commit c995ba8

Please sign in to comment.