Coder Social home page Coder Social logo

cartodb / cartoframes Goto Github PK

View Code? Open in Web Editor NEW
249.0 45.0 63.0 173.98 MB

CARTO Python package for data scientists

License: BSD 3-Clause "New" or "Revised" License

Python 91.61% Makefile 0.03% JavaScript 6.12% Jinja 2.24%
spatial-data-analysis carto data-science maps python jupyter-notebook

cartoframes's Introduction

CARTOframes

https://github.com/CartoDB/cartoframes/actions/workflows/cartoframes-ci.yml/badge.svg?branch=develop https://img.shields.io/badge/pypi-v1.2.4-orange

A Python package for integrating CARTO maps, analysis, and data services into data science workflows.

Python data analysis workflows often rely on the de facto standards pandas and Jupyter notebooks. 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 augmentation.

Try it Out

  • Stable (1.2.4): stable
  • Latest (develop branch): develop

If you do not have an API key, you can still use cartoframes for creating maps locally.

The example context only provides read access, so not all cartoframes features are available. For full access, Start a free trial or get free access with a GitHub Student Developer Pack.

Features

  • Create interactive maps from pandas DataFrames (CARTO account not required)
  • Publish interactive maps to CARTO's platform
  • Write and read pandas DataFrames to/from CARTO tables and queries
  • Create customizable, interactive CARTO maps in a Jupyter notebook using DataFrames or hosted data
  • Augment your data with CARTO's Data Observatory
  • Use CARTO for cloud-based analysis

Common Uses

  • Visualize spatial data programmatically as matplotlib images, as notebook-embedded interactive maps, or published map visualizations
  • Perform cloud-based spatial data processing using CARTO's analysis tools
  • Extract, transform, and Load (ETL) data using the Python ecosystem for getting data into and out of CARTO
  • Data Services integrations using CARTO's Location Data Streams

More info

cartoframes's People

Contributors

alasarr avatar alejandrohall avatar alrocar avatar andy-esch avatar antoniocarlon avatar arredond avatar cmongut avatar dgaubert avatar dmed256 avatar elenatorro avatar esloho avatar ethervoid avatar jesus89 avatar jgoizueta avatar josemazo avatar juanignaciosl avatar juanrmn avatar ljwolf avatar makella avatar malgar avatar martejpad avatar mehak-sachdeva avatar michellemho avatar mmoncadaisla avatar moicalcob avatar neokore avatar rjimenezda avatar shylpx avatar simon-contreras-deel avatar victorvelarde avatar

Stargazers

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

Watchers

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

cartoframes's Issues

abstract data type mapping to a separate class

These functions have some redundancies, and could be made more general/maintainable:

# TODO: combine this with other datatype maps
def map_dtypes(pgtype):
"""
Map PostgreSQL data types (key) to NumPy/pandas dtypes (value)
:param pgtype: string PostgreSQL/CARTO datatype to map to pandas data type
Output
:param : string data type used in pandas
"""
# may not be a complete list, could not find CARTO SQL API documentation
# about data types
dtypes = {'number': 'float64',
'date': 'datetime64',
'string': 'object',
'geometry': 'object',
'boolean': 'bool'}
try:
return dtypes[pgtype]
except KeyError:
# make it a string if not in dict above
return 'object'
def dtype_to_pgtype(dtype, colname):
"""
Map dataframe types to carto postgres types
"""
if colname in ('the_geom', 'the_geom_webmercator'):
return 'geometry'
else:
mapping = {'float64': 'numeric',
'int64': 'int',
'datetime64': 'date',
'object': 'text',
'bool': 'boolean'}
try:
return mapping[dtype]
except KeyError:
return 'text'
def map_numpy_to_postgres(item):
"""
Map NumPy values to PostgreSQL values
"""
import math
if isinstance(item, str):
if "'" in item:
return "'{}'".format(item.replace("'", "\'\'"))
return "'{}'".format(item)
elif isinstance(item, float):
if math.isnan(item):
return 'null'
return str(item)
elif item is None:
return 'null'
return str(item)
def datatype_map(dtype):
"""
map NumPy types to PostgreSQL types
"""
# TODO: add datetype conversion
if 'float' in dtype:
return 'numeric'
elif 'int' in dtype:
return 'int'
elif 'bool' in dtype:
return 'boolean'
else:
return 'text'

carto_map options

arguments :

Basic usage

  • stylecol
  • css (optional)
  • color_ramp (optional)
  • quantification_method (optional)
  • linear, log (optional)

Advanced

  • css (just whatever)

Static

Multimap!!!!!

  • stylecols = [ ]
  • synced = True

create a basemaps class

Extract existing code to make it more modular.

Let CartoCSS class inherit properties from Basemap instances.

methods for getting to carto data and maps pages

something like

  • df.get_datapage()
    • prints out the url where the data is displayed (publicly or through auth)
  • df.get_mappage()
    • prints out the url where the map is displayed (publicly or through auth)

Examples notebooks

Notebook showing the different ways to use the module

  • for each method/function
    • read_carto
    • sync from previous cartoframe
    • sync from new dataframe->cartoframe
    • carto_map
    • data observatory
  • data sci workflows (involving common operations, external libraries)

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.