Repository navigation
Store LatLong columns as object dtype containing tuples - #414
Conversation
| self._series = dd.from_pandas(formatted_series, npartitions=self._series.npartitions) | ||
| elif ks and isinstance(self._series, ks.Series): | ||
| formatted_series = self._series.to_pandas().apply(_reformat_to_latlong, use_list=True) | ||
| self._series = ks.from_pandas(formatted_series) |
There was a problem hiding this comment.
Ideally, we could just use apply on the dd and ks dataframes, but with Dask, we don't know the format of the data in the column (the "meta" like how it gets used in featuretools here. ), and with Koalas, there was an issue with User Defined Functions (UDFs).
There might be a better way of doing this conversion to the standard format, so I'm open to any suggestions here.
There was a problem hiding this comment.
Updated the dask apply to use apply directly on the Dask series (I wasn't thinking before, but of course we do know the desired format since the whole point of this is to get the standard tuple([str, str]) formatting.)
Still haven't found a better way to do the koalas apply, though.
|
|
||
| error = re.escape("LatLongs must either be a tuple, a list, or a string representation of a tuple. (1,2) does not fit the criteria.") | ||
| with pytest.raises(ValueError, match=error): | ||
| _reformat_to_latlong("'(1,2)'") |
There was a problem hiding this comment.
I don't know how you'd get this case as an input, but the error message here is misleading, and I'm wondering if we might want to handle this case.
Codecov Report
@@ Coverage Diff @@
## main #414 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 31 31
Lines 4065 4221 +156
==========================================
+ Hits 4065 4221 +156
Continue to review full report at Codecov.
|
243cc7d to
e288a60
Compare
dd58591 to
ae67d56
Compare
thehomebrewnerd
left a comment
There was a problem hiding this comment.
This is looking pretty good - one subject for discussion. In describe for LatLongs I think we are only including np.nan in our nan_count results, but we would not consider (np.nan, 43) or (np.nan, np.nan) as having missing values. I'm not sure what the right approach is here, but it sort of feels like (np.nan, np.nan) should be counted as missing. Not as sure about (np.nan, 43).
My initial thought is that an interesting way to do that would be to have latlong columns be three columns in the describe df: one for latlong, one for lat, and one for long. And for the separated out lat and long values we could do a wider array of calculations since they're numeric. Then again, is it useful to know the average latitude or the standard dev? For simplicity, though. I think conflating |
|
@tamargrey I think it's very dataset dependent if average latitude is useful or not. So the best we can do from a Woodwork perspective is to provide the information. So I like your idea of having 3 columns for describing a LatLong. We can do this in a follow up MR. No need to worry about that now.
|
ae67d56 to
537bca5
Compare
4bdec7f to
027add0
Compare
027add0 to
79f9824
Compare
thehomebrewnerd
left a comment
There was a problem hiding this comment.
Looks good to me!
objectso that we can store latlongs as tuples for easy access to their values