Skip to content

Commit

Permalink
Merge 159b778 into cb62e9f
Browse files Browse the repository at this point in the history
  • Loading branch information
jwass committed Sep 5, 2014
2 parents cb62e9f + 159b778 commit 68a54af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions geopandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import shapely.affinity as affinity

import numpy as np
import pandas as pd
from pandas import Series, DataFrame, MultiIndex

import geopandas as gpd
Expand Down Expand Up @@ -70,7 +71,7 @@ def _generate_sindex(self):
else:
stream = ((i, item.bounds, idx) for i, (idx, item) in
enumerate(self.geometry.iteritems()) if
item and not item.is_empty)
pd.notnull(item) and not item.is_empty)
try:
self._sindex = SpatialIndex(stream)
# What we really want here is an empty generator error, or
Expand Down Expand Up @@ -155,7 +156,7 @@ def exterior(self):
def interiors(self):
"""Return the interior rings of each polygon"""
# TODO: return empty list or None for non-polygons
return _geo_unary_op(self, 'interiors')
return _series_unary_op(self, 'interiors')

def representative_point(self):
"""Return a GeoSeries of points guaranteed to be in each geometry"""
Expand Down
10 changes: 5 additions & 5 deletions tests/test_geodataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def test_to_json_geom_col(self):

def test_to_json_na(self):
# Set a value as nan and make sure it's written
self.df['Shape_Area'][self.df['BoroName']=='Queens'] = np.nan
self.df.loc[self.df['BoroName']=='Queens', 'Shape_Area'] = np.nan

text = self.df.to_json()
data = json.loads(text)
Expand All @@ -241,8 +241,8 @@ def test_to_json_bad_na(self):
text = self.df.to_json(na='garbage')

def test_to_json_dropna(self):
self.df['Shape_Area'][self.df['BoroName']=='Queens'] = np.nan
self.df['Shape_Leng'][self.df['BoroName']=='Bronx'] = np.nan
self.df.loc[self.df['BoroName']=='Queens', 'Shape_Area'] = np.nan
self.df.loc[self.df['BoroName']=='Bronx', 'Shape_Leng'] = np.nan

text = self.df.to_json(na='drop')
data = json.loads(text)
Expand All @@ -263,8 +263,8 @@ def test_to_json_dropna(self):
self.assertEqual(len(props), 4)

def test_to_json_keepna(self):
self.df['Shape_Area'][self.df['BoroName']=='Queens'] = np.nan
self.df['Shape_Leng'][self.df['BoroName']=='Bronx'] = np.nan
self.df.loc[self.df['BoroName']=='Queens', 'Shape_Area'] = np.nan
self.df.loc[self.df['BoroName']=='Bronx', 'Shape_Leng'] = np.nan

text = self.df.to_json(na='keep')
data = json.loads(text)
Expand Down

0 comments on commit 68a54af

Please sign in to comment.