Skip to content

Commit

Permalink
Merge pull request #1130 from CartoDB/carto-data-frame
Browse files Browse the repository at this point in the history
Add CartoDataFrame class
  • Loading branch information
alasarr committed Nov 22, 2019
2 parents f8764f6 + 6338127 commit d973fa3
Show file tree
Hide file tree
Showing 85 changed files with 4,342 additions and 4,600 deletions.
25 changes: 18 additions & 7 deletions cartoframes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
__title__ = 'cartoframes'
__description__ = 'CARTO Python package for data scientists'
__version__ = '1.0b5'
__url__ = 'https://github.com/CartoDB/cartoframes'
__author__ = 'Andy Eschbacher'
__email__ = 'andy@carto.com'
__license__ = 'BSD'
from ._version import __version__
from .core.cartodataframe import CartoDataFrame
from .io.carto import read_carto, to_carto, has_table, delete_table, describe_table, \
update_table, copy_table, create_table_from_query


__all__ = [
'__version__',
'CartoDataFrame',
'read_carto',
'to_carto',
'has_table',
'delete_table',
'describe_table',
'update_table',
'copy_table',
'create_table_from_query'
]
1 change: 1 addition & 0 deletions cartoframes/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '1.0b5'
2 changes: 1 addition & 1 deletion cartoframes/assets/src/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var init = (function () {
compact: false
});

const FIT_BOUNDS_SETTINGS = { animate: false, padding: 50, maxZoom: 14 };
const FIT_BOUNDS_SETTINGS = { animate: false, padding: 50, maxZoom: 16 };

function format(value) {
if (Array.isArray(value)) {
Expand Down
2 changes: 1 addition & 1 deletion cartoframes/assets/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export const attributionControl = new mapboxgl.AttributionControl({
compact: false
});

export const FIT_BOUNDS_SETTINGS = { animate: false, padding: 50, maxZoom: 14 };
export const FIT_BOUNDS_SETTINGS = { animate: false, padding: 50, maxZoom: 16 };
File renamed without changes.
39 changes: 39 additions & 0 deletions cartoframes/core/cartodataframe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from geopandas import GeoDataFrame

from ..utils.geom_utils import generate_index, generate_geometry


class CartoDataFrame(GeoDataFrame):

def __init__(self, *args, **kwargs):
super(CartoDataFrame, self).__init__(*args, **kwargs)

@staticmethod
def from_carto(*args, **kwargs):
from ..io.carto import read_carto
return read_carto(*args, **kwargs)

@classmethod
def from_file(cls, filename, **kwargs):
gdf = GeoDataFrame.from_file(filename, **kwargs)
return cls(gdf)

@classmethod
def from_features(cls, features, **kwargs):
gdf = GeoDataFrame.from_features(features, **kwargs)
return cls(gdf)

def to_carto(self, *args, **kwargs):
from ..io.carto import to_carto
return to_carto(self, *args, **kwargs)

def convert(self, index_column=None, geom_column=None, lnglat_columns=None,
drop_index=True, drop_geom=True, drop_lnglat=True):
# Magic function
generate_index(self, index_column, drop_index)
generate_geometry(self, geom_column, lnglat_columns, drop_geom, drop_lnglat)
return self

def viz(self, *args, **kwargs):
from ..viz import Map, Layer
return Map(Layer(self, *args, **kwargs))
File renamed without changes.

0 comments on commit d973fa3

Please sign in to comment.