Skip to content

Commit

Permalink
Merge branch 'master' into timestamp_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-esch authored Jun 20, 2017
2 parents 408b7dd + f6e7fd4 commit 4f19091
Show file tree
Hide file tree
Showing 12 changed files with 2,185 additions and 475 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: python
python:
- '3.5'
- '3.6'
install:
- pip install .
- pip install -r requirements.txt
script:
- make test
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
init:
pip install -r requirements.txt

docs:
cd docs && make html

test:
nosetests -v test/

.PHONY: init docs test
25 changes: 17 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
CARTOFrames
===========

.. image:: https://travis-ci.org/CartoDB/cartoframes.svg?branch=master
:target: https://travis-ci.org/CartoDB/cartoframes

A Python package for integrating `CARTO <https://carto.com/>`__ maps and services into data science workflows.

Python data analysis workflows often rely on the de facto standards `pandas <http://pandas.pydata.org/>`__ and `Jupyter notebooks <http://jupyter.org/>`__. Integrating CARTO into this workflow saves data scientists time and energy by not having to export datasets as files or retain multiple copies of the data. Instead, CARTOFrames give the ability to communicate reproducible analysis while providing the ability to gain from CARTO's services like hosted, dynamic or static maps and `Data Observatory <https://carto.com/data-observatory/>`__ augmentation.
Expand All @@ -10,7 +13,7 @@ Complete documentation: https://cartodb.github.io/cartoframes/
Install Instructions
--------------------

`cartoframes` relies on `pandas <http://pandas.pydata.org/>`__ and a development version of the CARTO Python SDK (on branch `1.0.0 <https://github.com/CartoDB/carto-python/tree/1.0.0>`__). To install `cartoframes` on your machine, do the following:
`cartoframes` relies on `pandas <http://pandas.pydata.org/>`__ and the `CARTO Python SDK <https://github.com/CartoDB/carto-python/>`__). To install `cartoframes` on your machine, do the following:

.. code:: bash
Expand All @@ -35,23 +38,29 @@ Get table from CARTO, make changes in pandas, sync updates with CARTO:
.. code:: python
import cartoframes
cc = cartoframes.CartoContext('https://eschbacher.carto.com/', APIKEY)
# `base_url`s are of the form `http://{username}.carto.com/` for most users
cc = cartoframes.CartoContext(base_url='https://eschbacher.carto.com/',
api_key=APIKEY)
# read a table from your CARTO account to a DataFrame
df = cc.read('brooklyn_poverty_census_tracts')
# do fancy pandas operations (add/drop columns, change values, etc.)
df['poverty_per_pop'] = df['poverty_count'] / df['total_population']
# updates carto table with all changes from this session
# updates CARTO table with all changes from this session
cc.write(df, 'brooklyn_poverty_census_tracts', overwrite=True)
Associate an existing pandas DataFrame with CARTO.
Write an existing pandas DataFrame to CARTO.

.. code:: python
import pandas as pd
import cartoframes
df = pd.read_csv('acadia_biodiversity.csv')
cc = cartoframes.CartoContext(BASEURL, APIKEY)
cc = cartoframes.CartoContext(base_url=BASEURL,
api_key=APIKEY)
cc.write(df, 'acadia_biodiversity')
Expand All @@ -63,7 +72,8 @@ The following will embed a CARTO map in a Jupyter notebook, allowing for custom
.. code:: python
from cartoframes import Layer, BaseMap, styling
cc = cartoframes.CartoContext(BASEURL, APIKEY)
cc = cartoframes.CartoContext(base_url=BASEURL,
api_key=APIKEY)
cc.map(layers=[BaseMap('light'),
Layer('acadia_biodiversity',
color={'column': 'simpson_index',
Expand Down Expand Up @@ -95,6 +105,5 @@ Interact with CARTO's `Data Observatory <https://carto.com/docs/carto-engine/dat
{'numer_id': 'us.census.acs.B19013001'},
{'numer_id': 'us.census.acs.B17001002',
'normalization': 'predenominated'},]
df = cc.do_augment('transactions', data_obs_measures)
df = cc.data_augment('transactions', data_obs_measures)
df.head()
Loading

0 comments on commit 4f19091

Please sign in to comment.