-
Notifications
You must be signed in to change notification settings - Fork 132
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
Fixes slicing of feasibility table in keep_form_with_max_profit() in Developer.py #206
base: master
Are you sure you want to change the base?
Conversation
… from feasibility table. This happens when user passes list in forms parameter to pick() in developer
…vels() to get sliced data from feasibility table.
@apdjustino Thanks for the PR. I'm having trouble duplicating your issue: I have a DataFrame with residential, retail, and office forms. I passed Also, looks like the |
hi @pksohn, Here's a little info on what I'm seeing: I am feeding the developer.pick() method the feasibility table calculated through the proforma feasibility model. I calculate feasibility for all forms, and the resulting table has multi-indexed columns with each form (retail, residential, industrial, office, mixedoffice, mixedresidential). When I run the developer.pick() method and i pass the list ['retail', 'office', industrial'], the command new_buildings.forms.value_counts() on the output table indicates that retail, residential, and office are the forms picked by the developer model. Residential should not be in that list, if it's not passed? I do see some inconsistencies with this too; different combinations of forms will sometimes be correct and sometime incorrect. With the changes I submitted, I found that the forms in the new_buildings output were consistently matching the forms in the list passed to pick() method |
@apdjustino Interesting. Thanks for the additional info. I tried to use a simple test case to reproduce that behavior; let me know if I'm missing something here. I'm still getting the expected/correct result here: Added to test_developer.py:
|
Developer.pick() allows a list of forms passed to the forms parameter, which will slice the feasibility dataframe to include the forms in the list. When Pandas slices a df with a MultiIndex, it keeps all of the levels from the original df, even if they are not used. Since all the levels remain in MultiIndex of columns the sliced feasibility df, calling stack(level=0) on the sliced df will put forms that we are trying to exclude in the stacked output.
[Refer to the pandas docs] https://pandas.pydata.org/pandas-docs/stable/advanced.html#defined-levels) for more information about Defined Levels in pandas MultiIndex