Skip to content

Add numeric view of internal df #393

Description

@graceg571

Profiles and cleaned profiles have an internal df representation where rankings are composed of integer IDs rather than frozensets of candidates.

The internal df representation (profile._df) was introduced to map integer and string candidates to the same type internally but can also take advantage of numpy integer operations and vectorization. However, the internal df has Weight and Voter Set columns that can store objects beyond integers. A view or slice into the internal df as a purely numeric numpy array can be constructed instead where the Weight and Voter Set columns are stored as vectors. Voter Set can be recorded as empty when none are present and transformed to a column of empty frozensets when accessing the external df. Voter Set tends to be empty especially for generating profiles.

Many classes and operations act upon the profile's df and creates a new profile with the altered df. An internal can be added to ingest the internal df (avoiding the round trip of transforming to the external df and reconstructing the internal df for the new profile) and its candidate ID mapping.

The purely numeric ranking slice and its candidate ID mapping can serve as the serialization format for profiles.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions