Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behaviour when subsetting FlowDataFrame #270

Open
mauruscz opened this issue Sep 20, 2023 · 0 comments
Open

Strange behaviour when subsetting FlowDataFrame #270

mauruscz opened this issue Sep 20, 2023 · 0 comments

Comments

@mauruscz
Copy link
Collaborator

If I have a FlowDataFrame whose columns are

origin | destination | flow | attr_1 | attr_2

and I try to take a subset of column, it is only allowed when I only pick the origin OR the destination

Like

fdf[["origin", "flow"]] or fdf[["destination", "flow"]]

But if I do something like fdf["origin", "destination", "flow", "attr_1"] it fails with the error

File [/opt/anaconda3/envs/GSA/lib/python3.9/site-packages/skmob/core/flowdataframe.py:319](https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/GSA/lib/python3.9/site-packages/skmob/core/flowdataframe.py:319), in FlowDataFrame.__getitem__(self, key)
    314 """
    315 It the result contains lat, lng and datetime, return a TrajDataFrame, else a pandas DataFrame.
    316 """
    317 result = super(FlowDataFrame, self).__getitem__(key)
--> 319 if (isinstance(result, FlowDataFrame)) and result._is_flowdataframe():
    320     result.__class__ = FlowDataFrame
    321     result.tessellation = self._tessellation

File [/opt/anaconda3/envs/GSA/lib/python3.9/site-packages/skmob/core/flowdataframe.py:277](https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/GSA/lib/python3.9/site-packages/skmob/core/flowdataframe.py:277), in FlowDataFrame._is_flowdataframe(self)
    271 def _is_flowdataframe(self):
    273     if ((constants.ORIGIN in self) and
    274             pd.core.dtypes.common.is_string_dtype(self[constants.ORIGIN])) \
    275         and ((constants.DESTINATION in self) and
    276              pd.core.dtypes.common.is_string_dtype(self[constants.DESTINATION])) \
--> 277         and ((constants.TILE_ID in self._tessellation) and
    278              pd.core.dtypes.common.is_string_dtype(self._tessellation[constants.TILE_ID])) \
    279         and ((constants.FLOW in self) and
    280              (pd.core.dtypes.common.is_float_dtype(self[constants.FLOW]) or
    281               pd.core.dtypes.common.is_integer_dtype(self[constants.FLOW]))):
    282         return True
    284     return False

TypeError: argument of type 'NoneType' is not iterable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant