Skip to content

Keep default values in df_kwargs when calling load_data()#270

Merged
pwildenhain merged 12 commits into
redcap-tools:masterfrom
ugGit:master
Jul 5, 2023
Merged

Keep default values in df_kwargs when calling load_data()#270
pwildenhain merged 12 commits into
redcap-tools:masterfrom
ugGit:master

Conversation

@ugGit
Copy link
Copy Markdown
Contributor

@ugGit ugGit commented Jun 29, 2023

This PR implements issue #268.

Previously, the default values in the df_kwargs were overridden, even if no value was specified for them.
Now, the default values remain unchanged (e.g., for index_cols when using export_records(df_kwargs{'low_memory': False})).
Additionally, three test cases are implemented to verify the above described behavior, as well as the existing one.

Besides, the command to install poetry in the contribution guidelines is update.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 29, 2023

Codecov Report

Merging #270 (86d510f) into master (a507d1a) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 86d510f differs from pull request most recent head 674673b. Consider uploading reports for the commit 674673b to get more accurate results

@@            Coverage Diff            @@
##            master      #270   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           19        19           
  Lines          568       571    +3     
=========================================
+ Hits           568       571    +3     
Impacted Files Coverage Δ
redcap/methods/base.py 100.00% <100.00%> (ø)
redcap/methods/records.py 100.00% <100.00%> (ø)

Copy link
Copy Markdown
Collaborator

@pwildenhain pwildenhain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks great 🤩 just one consideration I have for the eav record type.

If the user asks for that then they'll be given one row per column per record, instead of the usual one row per record. So in that case we don't want to define an index_col

Comment thread CONTRIBUTING.md
Comment thread redcap/methods/base.py
],
format_type: Literal["json", "csv", "xml", "df"],
df_kwargs: Optional[Dict[str, Any]] = None,
record_type: Literal["flat", "eav"] = "flat",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you've removed this argument? I would still like to be able to have the user return a data frame for the eav record type option

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure anymore. I guess, I did not see, that content = 'report when calling _load_data() from export_records(). I modified the code to leave the df_kwargs unchanged for the eav record type option.

Comment thread redcap/methods/base.py
df_kwargs = {"index_col": "original_field_name"}
df_kwargs = {}

if "index_col" not in df_kwargs.keys() and record_type != "eav":
Copy link
Copy Markdown
Contributor Author

@ugGit ugGit Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check leaves the df_kwargs unchanged when the record type is eav. Let me know if that sounds reasonable. Else, I'll change it back to the previous behavior of defining an empty dict for df_kwargs.

Copy link
Copy Markdown
Collaborator

@pwildenhain pwildenhain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇🏻‍♂️ Thanks for contributing this improvement 🎉

@pwildenhain pwildenhain merged commit a168006 into redcap-tools:master Jul 5, 2023
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

Successfully merging this pull request may close these issues.

2 participants