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

Derive auxiliary for selective editing #139

Merged
merged 12 commits into from
Jan 24, 2025
Merged

Conversation

robertswh
Copy link
Collaborator

@robertswh robertswh commented Dec 18, 2024

Pull Request Title

Derive auxiliary variable for the selective editing output.

The functionality has been written and added to the output but hasn't been tested yet.

Summary

Derive the required auxiliary variables for Q49 for the selective editing output for SPP

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Checklists

This pull request meets the following requirements:

Creator Checklist

  • Installable with all dependencies recorded
  • Runs without error
  • Follows PEP8 and project-specific conventions
  • Appropriate use of comments, for example, no descriptive comments
  • Functions documented using Numpy style docstrings
  • Assumptions and decisions log considered and updated if appropriate
  • Unit tests have been updated to cover essential functionality for a reasonable range of inputs and conditions
  • Other forms of testing such as end-to-end and user-interface testing have been considered and updated as required

If you feel some of these conditions do not apply for this pull request, please
add a comment to explain why.

Reviewer Checklist

  • Test suite passes (locally as a minimum)
  • Peer reviewed with review recorded

Additional Information

Please provide any additional information or context that would help the reviewer understand the changes in this pull request.

Related Issues

Link any related issues or pull requests here.

dataframe[
(dataframe[period] == previous_period) & (dataframe[question_no] == 49)
][[imputation_class, construction_link, question_no]]
.drop_duplicates()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

maybe we should look for duplicates in imputation_class and question_no as a quick check?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if we have a generic validation, but something similar is done when producing SE outputs

@robertswh robertswh changed the title WIP: 712 derive auxiliary for se Derive auxiliary for selective editing Dec 21, 2024

standardising_factor["imputation_flags_adjustedresponse"] = standardising_factor[
question_output = pd.merge(standardising_factor, auxiliary_value, on=["reference", "imputation_class", "questioncode"], how="left")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

doesn't make sense to merge on reference and imputation_class, one or the other

@robertswh robertswh marked this pull request as ready for review January 14, 2025 12:15
Copy link
Collaborator

@Jday7879 Jday7879 left a comment

Choose a reason for hiding this comment

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

Code looks good to me, Nice work :) I've made a couple of small comments and one nitpick about using .loc to remove the double indexing, not sure which method is actually better though

@@ -28,7 +30,7 @@ def calculate_predicted_value(
and imputed_value

"""

# TODO: This has already been combined somewhere updstream
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this function still needed in the pipeline. From what I can see its only called in unit tests

name of column in dataframe containing construction link variable
imputation_class : str
name of column in dataframe containing imputation class, where
there is one contruction link per imputation_class and period
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
there is one contruction link per imputation_class and period
there is one construction link per imputation_class and period

q40["auxiliary_value"] = q40[frozen_turnover]

previous_period = period_selected - pd.DateOffset(months=1)
prev_const_link = (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: Could maybe refactor to use .loc not sure which one is better in the long term?

dataframe.loc[
    (dataframe[period] == previous_period) & (dataframe[question_no] == 49),
    [imputation_class, construction_link, question_no]
]

dataframe[
(dataframe[period] == previous_period) & (dataframe[question_no] == 49)
][[imputation_class, construction_link, question_no]]
.drop_duplicates()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if we have a generic validation, but something similar is done when producing SE outputs

Copy link
Collaborator

@Jday7879 Jday7879 left a comment

Choose a reason for hiding this comment

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

Changing PR from approved to request changes to avoid it being merged early following todays stand-up

@Jday7879 Jday7879 dismissed their stale review January 23, 2025 13:36

I am continuing this work. Removing this review so that others can approve without me changing the review

Copy link
Collaborator

@Jday7879 Jday7879 left a comment

Choose a reason for hiding this comment

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

Looks good to me, merging :)

@Jday7879 Jday7879 merged commit b2a0fb8 into main Jan 24, 2025
8 checks passed
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.

3 participants