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

Additional methods and fixes to DataFrameMixin #43

Merged
merged 43 commits into from
Aug 1, 2024

Conversation

adamamer20
Copy link
Collaborator

This PR adds some useful methods to DataFrameMixin and fixes the logic of some methods in pandas and polars.
Added methods:

  • remove: remove values from DF based on a mask
  • add: equivalent of df.add from pandas
  • all: equivalent of df.all from pandas
  • column_names
  • div: equivalent of df.div from pandas
  • drop_columns
  • drop_duplicates
  • filter: remove values with a boolean dataframe
  • groupby_cum_count: equivalent of df.group_by.cum_count from pandas
  • join: equivalent of df.join from pandas
  • mul: equivalent of df.mul from pandas
  • norm: obtain a series with the L2 norm per every row in the DF
  • reset_index: equivalent of df.reset_index in pandas
  • set_index: equivalent of df.set_index in pandas
  • with_columns: equivalent of df.with_columns in polars
  • contains: equivalent to srs.contains in pandas
  • range: get the series of a specified range (start, end, step)
  • srs_to_df: convert series to DF

- create set_cells at DiscreteSpaceDF level
- created concrete swap in SpaceDF
- update due to changes in mixin
- add remaining capacity property
- branching _update_capacity in cells and agents
- added some useful method (add, all, div, drop_columns, drop_duplicates, group_by_cum_count, mul, norm, reset_index, set_index, srs_to_df)
- minor fixes
…nts are already present, the second if agents aren't already present

- Fixes to the logic of some methods of SpaceDF (random_agents, swap_agents),
DiscreteSpaceDF (__repr__, __str__)
GridDF (__init__, get_directions, get_distances, get_neighbors, get_neighborhood, get_cells, out_of_bounds, remove_agents, torus_adj, _compute_offsets, _get_df_coords)
- added custom _empty_cell_condition
- fixed the logic of some methods (_generate_empty_grid, _sample_cells, _update_capacity_agents, remaining_capacity)
@adamamer20 adamamer20 self-assigned this Aug 1, 2024
@adamamer20 adamamer20 added the enhancement Improvements to existing features or performance. label Aug 1, 2024
@adamamer20 adamamer20 mentioned this pull request Aug 1, 2024
@adamamer20 adamamer20 requested a review from rht August 1, 2024 19:27
@adamamer20 adamamer20 added this to the 0.1.0 Alpha Release milestone Aug 1, 2024
@rht
Copy link
Contributor

rht commented Aug 1, 2024

Tangent: it seems to me it could be its useful own package for a general DF with either pandas or Polars backend. Useful for people who can't decide which one to use, like us, haha. Otherwise, to add a selling point, we could implement R's dplyr-style grammar of data manipulation. Though there is already https://github.com/machow/siuba.

@rht rht merged commit 43f3baa into main Aug 1, 2024
6 checks passed
@rht rht deleted the addition-and-fixes-to-DataFrameMixin branch August 1, 2024 20:04
@adamamer20
Copy link
Collaborator Author

Agree! A separate package with a unique interface for any DF library could be worthwile, especially since there are methods which are almost the same with only a name change. However right now I wrote up just the methods I needed so far. We can think about it when the library is a bit more mature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements to existing features or performance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants