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

Aggregate with exponential decay #127

Open
rolocampusano opened this issue Oct 15, 2019 · 3 comments
Open

Aggregate with exponential decay #127

rolocampusano opened this issue Oct 15, 2019 · 3 comments

Comments

@rolocampusano
Copy link

Description of the bug

I'm creating a value of land access for each node where I want to sum de land area a node can access within 1000m with exponential distance decay. The data is summed from a grid cell so I first attach each grid centroid to the closest node and then sum from then. The network I'm using is obtain through the osm loader and the aggregation works just fine when I use linear decay but when I use exponential decay I get the following panda error.

ValueError: Length of passed values is 0, index implies 326262

Environment

  • Operating system: macOS Mojave or Catalina
  • Python version: 3.7
  • Pandana version: 0.4.4

Paste the code that reproduces the issue here:

x, y = grid_land_data.grid_index_x, grid_land_data.grid_index_y
grid_land_data["node_ids"] = network.get_node_ids(x, y)

network.set(grid_land_data["node_ids"], variable=grid_land_data['area_Parks'], name="area_Parks")
s = network.aggregate(1000, type='sum', decay='exponential', name="area_Parks")

Whole error message

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-48-e2900f6bc766> in <module>
      4 for use in uses:
      5     network.set(grid_land_data["node_ids"], variable=grid_land_data['area_'+str(use)], name="area_"+str(use))
----> 6     s = network.aggregate(200, type=aggregation, decay=decay, name="area_"+str(use))
      7     s = pd.DataFrame(data = s.values, index=s.index)
      8 

~/.conda/envs/research/lib/python3.7/site-packages/pandana/network.py in aggregate(self, distance, type, decay, imp_name, name)
    351                                                                  imp_num)
    352 
--> 353         return pd.Series(res, index=self.node_ids)
    354 
    355     def get_node_ids(self, x_col, y_col, mapping_distance=None):

~/.conda/envs/research/lib/python3.7/site-packages/pandas/core/series.py in __init__(self, data, index, dtype, name, copy, fastpath)
    297                         raise ValueError(
    298                             "Length of passed values is {val}, "
--> 299                             "index implies {ind}".format(val=len(data), ind=len(index))
    300                         )
    301                 except TypeError:

ValueError: Length of passed values is 0, index implies 326262
@knaaptime
Copy link

i meant to raise an issue earlier (especially because now I cant remember how I discovered the fix) but there's an error in the docs. To use exponential decay, I believe you have to use decay='exp' not exponential

@rolocampusano
Copy link
Author

This is great. It worked! Should I change the issue so that there is a fix in the docs?

@d-wasserman
Copy link

This is still in the documentation. Would a PR be well received for a correction?

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

3 participants