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

Provide means to use rowkeys without an existing column; fully symmetric will easily support transposition/flip. #9

Open
raylutz opened this issue Apr 1, 2024 · 0 comments

Comments

@raylutz
Copy link
Owner

raylutz commented Apr 1, 2024

Current:

rowkeys can be initialized only if there is an existing column with those values. Then, those values are copied to an indexing dictionary to create the lookup mechanism. There is no means to create a rowkeys lookup dict without an existing column of values.

Problem:

  • Transposing daf object would require the creation of a new column to maintain column keys and create the keyfield and kd.
  • It may be desirable to keep rowkeys separated from the data rows, so the entire row can be used in calculations, such as sum().
  • structure is currently not symmetrical, so it is not possible to treat rows as columns. Treating rows as if they are columns means they can be processed using conventional list-oriented functions, such as sum().

Proposed:

Create method to initialize kd dict without an existing column.

  • if kd == {} and keyfield == '': then no kd is created.
  • if keyfield, then initialize kd from that column. keyfield != '' and kd != {}.
  • kd can be initialized from any list, even if keyfield == '' using daf.set_rowkeys(keylist) method
    • This will initialize kd as a indexing dict.
    • create error if the keylist has any duplicative values or cannot be hashed.
    • kd != {} and keyfield == '' indicates this situation.
  • update other cases when the kd is rebuilt. Can't be rebuilt in the same way if keyfield == ''.
  • When transpose or "flip" is indicated when columns are selected, then:
    • column names are used as rowkey values and kd is built without a corresponding keyfield column.
    • if rowkey values exist prior to flipping, then those will be used as column names.
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