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

🎉 Enable converting from long to wide format in grapher step #3674

Merged
merged 17 commits into from
Dec 13, 2024

Conversation

Marigold
Copy link
Collaborator

@Marigold Marigold commented Dec 2, 2024

Enable the conversion from long to wide format directly in the data://grapher step, rather than relying on a grapher://grapher step. This is achieved by using the long_to_wide=True parameter in the create_dataset function.

YAML metadata is updated twice: once for the long format and once for the wide format. This dual update allows for the use of Jinja templating with non-flattened indicator names while also supporting metadata for flattened indicators. A typical use case would involve overwriting specific indicators that fall outside the scope of the Jinja framework.

In practice, adding long_to_wide=True changes only the format (long → wide) in which tables are saved. The implementation remains backward compatible with existing steps.

TODO

  • Investigate performance implications—health datasets are currently saved in long format, and saving them in wide format could introduce inefficiencies.
  • Set long_to_wide=True as the default and increment ETL_EPOCH to evaluate differences.
  • Undo ETL_EPOCH

@owidbot
Copy link
Contributor

owidbot commented Dec 2, 2024

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-long-to-wide

chart-diff: ✅ No charts for review.
data-diff: ❌ Found differences
= Dataset garden/antibiotics/2024-11-12/antimicrobial_usage
  = Table class
  = Table aware
  = Table class_aggregated
    ~ Column ddd_antibacterials_and_antituberculosis (changed metadata)
-       -   - 'For Portugal: data are incomplete for antituberculosis medicines.'
+       +   - 'For Austria, Germany and Iceland: only antimicrobial consumption in the community is reported.'
+       +   - 'For Bhutan, Burkina Faso and Sudan: for antibiotics, only antibiotics for systemic use (ATC code J01) are reported'
+       +   - 'For Kenya: data is incomplete since it''s not collected from all sources.'
-       -   - 'For Austria, Germany and Iceland: only antimicrobial consumption in the community is reported.'
-       -   - 'For Bhutan, Burkina Faso and Sudan: for antibiotics, only antibiotics for systemic use (ATC code J01) are reported'
+       +   - 'For Portugal: data are incomplete for antituberculosis medicines.'
+       +   - 'For Nepal: data is incomplete, not all antibiotics reported systematically.'
-       -   - 'For Kenya: data is incomplete since it''s not collected from all sources.'
-       -   - 'For Nepal: data is incomplete, not all antibiotics reported systematically.'
    ~ Column ddd_antifungals (changed metadata)
+       +   - 'For Austria, Germany and Iceland: only antimicrobial consumption in the community is reported.'
-       -   - 'For Austria, Germany and Iceland: only antimicrobial consumption in the community is reported.'
+       +   - 'For Ireland: for antifungals, only those used in hospitals are reported.'
-       -   - 'For Ireland: for antifungals, only those used in hospitals are reported.'
    ~ Column ddd_antivirals (changed metadata)
+       +   - 'For Nepal: data is incomplete, not all antibiotics reported systematically.'
-       -   - 'For Nepal: data is incomplete, not all antibiotics reported systematically.'
    ~ Column did_antibacterials_and_antituberculosis (changed metadata)
-       -   - 'For Portugal: data are incomplete for antituberculosis medicines.'
+       +   - 'For Austria, Germany and Iceland: only antimicrobial consumption in the community is reported.'
+       +   - 'For Bhutan, Burkina Faso and Sudan: for antibiotics, only antibiotics for systemic use (ATC code J01) are reported'
+       +   - 'For Kenya: data is incomplete since it''s not collected from all sources.'
-       -   - 'For Austria, Germany and Iceland: only antimicrobial consumption in the community is reported.'
-       -   - 'For Bhutan, Burkina Faso and Sudan: for antibiotics, only antibiotics for systemic use (ATC code J01) are reported'
+       +   - 'For Portugal: data are incomplete for antituberculosis medicines.'
+       +   - 'For Nepal: data is incomplete, not all antibiotics reported systematically.'
-       -   - 'For Kenya: data is incomplete since it''s not collected from all sources.'
-       -   - 'For Nepal: data is incomplete, not all antibiotics reported systematically.'
    ~ Column did_antifungals (changed metadata)
+       +   - 'For Austria, Germany and Iceland: only antimicrobial consumption in the community is reported.'
-       -   - 'For Austria, Germany and Iceland: only antimicrobial consumption in the community is reported.'
+       +   - 'For Ireland: for antifungals, only those used in hospitals are reported.'
-       -   - 'For Ireland: for antifungals, only those used in hospitals are reported.'
    ~ Column did_antivirals (changed metadata)
+       +   - 'For Nepal: data is incomplete, not all antibiotics reported systematically.'
-       -   - 'For Nepal: data is incomplete, not all antibiotics reported systematically.'
= Dataset garden/health/2023-05-04/global_wellbeing
  = Table global_wellbeing
    ~ Dim country
+       + New values: 816 / 21632 (3.77%)
           year                              dimension                                       answer     country
           2020 (Urban/Rural?) A small town or village                                           No   Australia
           2020 (Urban/Rural?) A small town or village                             An exciting life     Bahrain
           2020 (Urban/Rural?) A small town or village           Helping other people who need help     Denmark
           2020 (Urban/Rural?) A small town or village                                          Yes New Zealand
           2020 (Urban/Rural?) A small town or village Being good at what you do in your daily life South Korea
-       - Removed values: 816 / 21632 (3.77%)
           year                              dimension                                       answer     country
           2020 (Urban/Rural?) A small town or villAge                                           No   Australia
           2020 (Urban/Rural?) A small town or villAge                             An exciting life     Bahrain
           2020 (Urban/Rural?) A small town or villAge           Helping other people who need help     Denmark
           2020 (Urban/Rural?) A small town or villAge                                          Yes New Zealand
           2020 (Urban/Rural?) A small town or villAge Being good at what you do in your daily life South Korea
    ~ Dim year
+       + New values: 816 / 21632 (3.77%)
              country                              dimension                                       answer  year
            Australia (Urban/Rural?) A small town or village                                           No  2020
              Bahrain (Urban/Rural?) A small town or village                             An exciting life  2020
              Denmark (Urban/Rural?) A small town or village           Helping other people who need help  2020
          New Zealand (Urban/Rural?) A small town or village                                          Yes  2020
          South Korea (Urban/Rural?) A small town or village Being good at what you do in your daily life  2020
-       - Removed values: 816 / 21632 (3.77%)
              country                              dimension                                       answer  year
            Australia (Urban/Rural?) A small town or villAge                                           No  2020
              Bahrain (Urban/Rural?) A small town or villAge                             An exciting life  2020
              Denmark (Urban/Rural?) A small town or villAge           Helping other people who need help  2020
          New Zealand (Urban/Rural?) A small town or villAge                                          Yes  2020
          South Korea (Urban/Rural?) A small town or villAge Being good at what you do in your daily life  2020
    ~ Dim dimension
+       + New values: 816 / 21632 (3.77%)
              country  year                                       answer                              dimension
            Australia  2020                                           No (Urban/Rural?) A small town or village
              Bahrain  2020                             An exciting life (Urban/Rural?) A small town or village
              Denmark  2020           Helping other people who need help (Urban/Rural?) A small town or village
          New Zealand  2020                                          Yes (Urban/Rural?) A small town or village
          South Korea  2020 Being good at what you do in your daily life (Urban/Rural?) A small town or village
-       - Removed values: 816 / 21632 (3.77%)
              country  year                                       answer                              dimension
            Australia  2020                                           No (Urban/Rural?) A small town or villAge
              Bahrain  2020                             An exciting life (Urban/Rural?) A small town or villAge
              Denmark  2020           Helping other people who need help (Urban/Rural?) A small town or villAge
          New Zealand  2020                                          Yes (Urban/Rural?) A small town or villAge
          South Korea  2020 Being good at what you do in your daily life (Urban/Rural?) A small town or villAge
    ~ Dim answer
+       + New values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer
            Australia  2020 (Urban/Rural?) A small town or village                                           No
              Bahrain  2020 (Urban/Rural?) A small town or village                             An exciting life
              Denmark  2020 (Urban/Rural?) A small town or village           Helping other people who need help
          New Zealand  2020 (Urban/Rural?) A small town or village                                          Yes
          South Korea  2020 (Urban/Rural?) A small town or village Being good at what you do in your daily life
-       - Removed values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer
            Australia  2020 (Urban/Rural?) A small town or villAge                                           No
              Bahrain  2020 (Urban/Rural?) A small town or villAge                             An exciting life
              Denmark  2020 (Urban/Rural?) A small town or villAge           Helping other people who need help
          New Zealand  2020 (Urban/Rural?) A small town or villAge                                          Yes
          South Korea  2020 (Urban/Rural?) A small town or villAge Being good at what you do in your daily life
    ~ Column count_on_to_help (new data, changed data)
+       + New values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  count_on_to_help
            Australia  2020 (Urban/Rural?) A small town or village                                           No          9.515144
              Bahrain  2020 (Urban/Rural?) A small town or village                             An exciting life              <NA>
              Denmark  2020 (Urban/Rural?) A small town or village           Helping other people who need help              <NA>
          New Zealand  2020 (Urban/Rural?) A small town or village                                          Yes         94.002441
          South Korea  2020 (Urban/Rural?) A small town or village Being good at what you do in your daily life              <NA>
-       - Removed values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  count_on_to_help
            Australia  2020 (Urban/Rural?) A small town or villAge                                           No          9.515144
              Bahrain  2020 (Urban/Rural?) A small town or villAge                             An exciting life              <NA>
              Denmark  2020 (Urban/Rural?) A small town or villAge           Helping other people who need help              <NA>
          New Zealand  2020 (Urban/Rural?) A small town or villAge                                          Yes         94.002441
          South Korea  2020 (Urban/Rural?) A small town or villAge Being good at what you do in your daily life              <NA>
    ~ Column enjoy_the_work_you_do_every_day (new data, changed data)
+       + New values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  enjoy_the_work_you_do_every_day
            Australia  2020 (Urban/Rural?) A small town or village                                           No                        21.584761
              Bahrain  2020 (Urban/Rural?) A small town or village                             An exciting life                             <NA>
              Denmark  2020 (Urban/Rural?) A small town or village           Helping other people who need help                             <NA>
          New Zealand  2020 (Urban/Rural?) A small town or village                                          Yes                        83.966133
          South Korea  2020 (Urban/Rural?) A small town or village Being good at what you do in your daily life                             <NA>
-       - Removed values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  enjoy_the_work_you_do_every_day
            Australia  2020 (Urban/Rural?) A small town or villAge                                           No                        21.584761
              Bahrain  2020 (Urban/Rural?) A small town or villAge                             An exciting life                             <NA>
              Denmark  2020 (Urban/Rural?) A small town or villAge           Helping other people who need help                             <NA>
          New Zealand  2020 (Urban/Rural?) A small town or villAge                                          Yes                        83.966133
          South Korea  2020 (Urban/Rural?) A small town or villAge Being good at what you do in your daily life                             <NA>
    ~ Column exciting_life_or_calm_life (new data, changed data)
+       + New values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  exciting_life_or_calm_life
            Australia  2020 (Urban/Rural?) A small town or village                                           No                        <NA>
              Bahrain  2020 (Urban/Rural?) A small town or village                             An exciting life                   18.243595
              Denmark  2020 (Urban/Rural?) A small town or village           Helping other people who need help                        <NA>
          New Zealand  2020 (Urban/Rural?) A small town or village                                          Yes                        <NA>
          South Korea  2020 (Urban/Rural?) A small town or village Being good at what you do in your daily life                        <NA>
-       - Removed values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  exciting_life_or_calm_life
            Australia  2020 (Urban/Rural?) A small town or villAge                                           No                        <NA>
              Bahrain  2020 (Urban/Rural?) A small town or villAge                             An exciting life                   18.243595
              Denmark  2020 (Urban/Rural?) A small town or villAge           Helping other people who need help                        <NA>
          New Zealand  2020 (Urban/Rural?) A small town or villAge                                          Yes                        <NA>
          South Korea  2020 (Urban/Rural?) A small town or villAge Being good at what you do in your daily life                        <NA>
    ~ Column experience_calmness_yesterday (new data, changed data)
+       + New values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  experience_calmness_yesterday
            Australia  2020 (Urban/Rural?) A small town or village                                           No                      20.294548
              Bahrain  2020 (Urban/Rural?) A small town or village                             An exciting life                           <NA>
              Denmark  2020 (Urban/Rural?) A small town or village           Helping other people who need help                           <NA>
          New Zealand  2020 (Urban/Rural?) A small town or village                                          Yes                      80.558983
          South Korea  2020 (Urban/Rural?) A small town or village Being good at what you do in your daily life                           <NA>
-       - Removed values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  experience_calmness_yesterday
            Australia  2020 (Urban/Rural?) A small town or villAge                                           No                      20.294548
              Bahrain  2020 (Urban/Rural?) A small town or villAge                             An exciting life                           <NA>
              Denmark  2020 (Urban/Rural?) A small town or villAge           Helping other people who need help                           <NA>
          New Zealand  2020 (Urban/Rural?) A small town or villAge                                          Yes                      80.558983
          South Korea  2020 (Urban/Rural?) A small town or villAge Being good at what you do in your daily life                           <NA>
    ~ Column feel_at_peace_with_life (new data, changed data)
+       + New values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  feel_at_peace_with_life
            Australia  2020 (Urban/Rural?) A small town or village                                           No                11.713309
              Bahrain  2020 (Urban/Rural?) A small town or village                             An exciting life                     <NA>
              Denmark  2020 (Urban/Rural?) A small town or village           Helping other people who need help                     <NA>
          New Zealand  2020 (Urban/Rural?) A small town or village                                          Yes                88.314369
          South Korea  2020 (Urban/Rural?) A small town or village Being good at what you do in your daily life                     <NA>
-       - Removed values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  feel_at_peace_with_life
            Australia  2020 (Urban/Rural?) A small town or villAge                                           No                11.713309
              Bahrain  2020 (Urban/Rural?) A small town or villAge                             An exciting life                     <NA>
              Denmark  2020 (Urban/Rural?) A small town or villAge           Helping other people who need help                     <NA>
          New Zealand  2020 (Urban/Rural?) A small town or villAge                                          Yes                88.314369
          South Korea  2020 (Urban/Rural?) A small town or villAge Being good at what you do in your daily life                     <NA>
    ~ Column focus_on_taking_care_of_themselves_or_taking_care_of_others (new data, changed data)
+       + New values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  focus_on_taking_care_of_themselves_or_taking_care_of_others
            Australia  2020 (Urban/Rural?) A small town or village                                           No                                                         <NA>
              Bahrain  2020 (Urban/Rural?) A small town or village                             An exciting life                                                         <NA>
              Denmark  2020 (Urban/Rural?) A small town or village           Helping other people who need help                                                         <NA>
          New Zealand  2020 (Urban/Rural?) A small town or village                                          Yes                                                         <NA>
          South Korea  2020 (Urban/Rural?) A small town or village Being good at what you do in your daily life                                                         <NA>
-       - Removed values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  focus_on_taking_care_of_themselves_or_taking_care_of_others
            Australia  2020 (Urban/Rural?) A small town or villAge                                           No                                                         <NA>
              Bahrain  2020 (Urban/Rural?) A small town or villAge                             An exciting life                                                         <NA>
              Denmark  2020 (Urban/Rural?) A small town or villAge           Helping other people who need help                                                         <NA>
          New Zealand  2020 (Urban/Rural?) A small town or villAge                                          Yes                                                         <NA>
          South Korea  2020 (Urban/Rural?) A small town or villAge Being good at what you do in your daily life                                                         <NA>
    ~ Column health_problems (new data, changed data)
+       + New values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  health_problems
            Australia  2020 (Urban/Rural?) A small town or village                                           No        74.723564
              Bahrain  2020 (Urban/Rural?) A small town or village                             An exciting life             <NA>
              Denmark  2020 (Urban/Rural?) A small town or village           Helping other people who need help             <NA>
          New Zealand  2020 (Urban/Rural?) A small town or village                                          Yes        25.686413
          South Korea  2020 (Urban/Rural?) A small town or village Being good at what you do in your daily life             <NA>
-       - Removed values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  health_problems
            Australia  2020 (Urban/Rural?) A small town or villAge                                           No        74.723564
              Bahrain  2020 (Urban/Rural?) A small town or villAge                             An exciting life             <NA>
              Denmark  2020 (Urban/Rural?) A small town or villAge           Helping other people who need help             <NA>
          New Zealand  2020 (Urban/Rural?) A small town or villAge                                          Yes        25.686413
          South Korea  2020 (Urban/Rural?) A small town or villAge Being good at what you do in your daily life             <NA>
    ~ Column main_purpose_in_life (new data, changed data)
+       + New values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  main_purpose_in_life
            Australia  2020 (Urban/Rural?) A small town or village                                           No                  <NA>
              Bahrain  2020 (Urban/Rural?) A small town or village                             An exciting life                  <NA>
              Denmark  2020 (Urban/Rural?) A small town or village           Helping other people who need help              14.41984
          New Zealand  2020 (Urban/Rural?) A small town or village                                          Yes                  <NA>
          South Korea  2020 (Urban/Rural?) A small town or village Being good at what you do in your daily life             57.775646
-       - Removed values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  main_purpose_in_life
            Australia  2020 (Urban/Rural?) A small town or villAge                                           No                  <NA>
              Bahrain  2020 (Urban/Rural?) A small town or villAge                             An exciting life                  <NA>
              Denmark  2020 (Urban/Rural?) A small town or villAge           Helping other people who need help              14.41984
          New Zealand  2020 (Urban/Rural?) A small town or villAge                                          Yes                  <NA>
          South Korea  2020 (Urban/Rural?) A small town or villAge Being good at what you do in your daily life             57.775646
    ~ Column many_choices_in_type_of_work (new data, changed data)
+       + New values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  many_choices_in_type_of_work
            Australia  2020 (Urban/Rural?) A small town or village                                           No                     33.097359
              Bahrain  2020 (Urban/Rural?) A small town or village                             An exciting life                          <NA>
              Denmark  2020 (Urban/Rural?) A small town or village           Helping other people who need help                          <NA>
          New Zealand  2020 (Urban/Rural?) A small town or village                                          Yes                     79.379234
          South Korea  2020 (Urban/Rural?) A small town or village Being good at what you do in your daily life                          <NA>
-       - Removed values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  many_choices_in_type_of_work
            Australia  2020 (Urban/Rural?) A small town or villAge                                           No                     33.097359
              Bahrain  2020 (Urban/Rural?) A small town or villAge                             An exciting life                          <NA>
              Denmark  2020 (Urban/Rural?) A small town or villAge           Helping other people who need help                          <NA>
          New Zealand  2020 (Urban/Rural?) A small town or villAge                                          Yes                     79.379234
          South Korea  2020 (Urban/Rural?) A small town or villAge Being good at what you do in your daily life                          <NA>
    ~ Column various_aspects_of_life_in_balance (new data, changed data)
+       + New values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  various_aspects_of_life_in_balance
            Australia  2020 (Urban/Rural?) A small town or village                                           No                           22.593025
              Bahrain  2020 (Urban/Rural?) A small town or village                             An exciting life                                <NA>
              Denmark  2020 (Urban/Rural?) A small town or village           Helping other people who need help                                <NA>
          New Zealand  2020 (Urban/Rural?) A small town or village                                          Yes                           79.808517
          South Korea  2020 (Urban/Rural?) A small town or village Being good at what you do in your daily life                                <NA>
-       - Removed values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  various_aspects_of_life_in_balance
            Australia  2020 (Urban/Rural?) A small town or villAge                                           No                           22.593025
              Bahrain  2020 (Urban/Rural?) A small town or villAge                             An exciting life                                <NA>
              Denmark  2020 (Urban/Rural?) A small town or villAge           Helping other people who need help                                <NA>
          New Zealand  2020 (Urban/Rural?) A small town or villAge                                          Yes                           79.808517
          South Korea  2020 (Urban/Rural?) A small town or villAge Being good at what you do in your daily life                                <NA>
    ~ Column work_significantly_improves_the_lives_of_others_outside_of_household (new data, changed data)
+       + New values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  work_significantly_improves_the_lives_of_others_outside_of_household
            Australia  2020 (Urban/Rural?) A small town or village                                           No                                                              24.82954
              Bahrain  2020 (Urban/Rural?) A small town or village                             An exciting life                                                                  <NA>
              Denmark  2020 (Urban/Rural?) A small town or village           Helping other people who need help                                                                  <NA>
          New Zealand  2020 (Urban/Rural?) A small town or village                                          Yes                                                             77.906219
          South Korea  2020 (Urban/Rural?) A small town or village Being good at what you do in your daily life                                                                  <NA>
-       - Removed values: 816 / 21632 (3.77%)
              country  year                              dimension                                       answer  work_significantly_improves_the_lives_of_others_outside_of_household
            Australia  2020 (Urban/Rural?) A small town or villAge                                           No                                                              24.82954
              Bahrain  2020 (Urban/Rural?) A small town or villAge                             An exciting life                                                                  <NA>
              Denmark  2020 (Urban/Rural?) A small town or villAge           Helping other people who need help                                                                  <NA>
          New Zealand  2020 (Urban/Rural?) A small town or villAge                                          Yes                                                             77.906219
          South Korea  2020 (Urban/Rural?) A small town or villAge Being good at what you do in your daily life                                                                  <NA>
  = Table global_wellbeing_index
    ~ Dim country
+       + New values: 51 / 1352 (3.77%)
           year                              dimension     country
           2020 (Urban/Rural?) A small town or village     Austria
           2020 (Urban/Rural?) A small town or village     Croatia
           2020 (Urban/Rural?) A small town or village      Cyprus
           2020 (Urban/Rural?) A small town or village       Italy
           2020 (Urban/Rural?) A small town or village New Zealand
-       - Removed values: 51 / 1352 (3.77%)
           year                              dimension     country
           2020 (Urban/Rural?) A small town or villAge     Austria
           2020 (Urban/Rural?) A small town or villAge     Croatia
           2020 (Urban/Rural?) A small town or villAge      Cyprus
           2020 (Urban/Rural?) A small town or villAge       Italy
           2020 (Urban/Rural?) A small town or villAge New Zealand
    ~ Dim year
+       + New values: 51 / 1352 (3.77%)
              country                              dimension  year
              Austria (Urban/Rural?) A small town or village  2020
              Croatia (Urban/Rural?) A small town or village  2020
               Cyprus (Urban/Rural?) A small town or village  2020
                Italy (Urban/Rural?) A small town or village  2020
          New Zealand (Urban/Rural?) A small town or village  2020
-       - Removed values: 51 / 1352 (3.77%)
              country                              dimension  year
              Austria (Urban/Rural?) A small town or villAge  2020
              Croatia (Urban/Rural?) A small town or villAge  2020
               Cyprus (Urban/Rural?) A small town or villAge  2020
                Italy (Urban/Rural?) A small town or villAge  2020
          New Zealand (Urban/Rural?) A small town or villAge  2020
    ~ Dim dimension
+       + New values: 51 / 1352 (3.77%)
              country  year                              dimension
              Austria  2020 (Urban/Rural?) A small town or village
              Croatia  2020 (Urban/Rural?) A small town or village
               Cyprus  2020 (Urban/Rural?) A small town or village
                Italy  2020 (Urban/Rural?) A small town or village
          New Zealand  2020 (Urban/Rural?) A small town or village
-       - Removed values: 51 / 1352 (3.77%)
              country  year                              dimension
              Austria  2020 (Urban/Rural?) A small town or villAge
              Croatia  2020 (Urban/Rural?) A small town or villAge
               Cyprus  2020 (Urban/Rural?) A small town or villAge
                Italy  2020 (Urban/Rural?) A small town or villAge
          New Zealand  2020 (Urban/Rural?) A small town or villAge
    ~ Column struggling_index (new data, changed data)
+       + New values: 51 / 1352 (3.77%)
              country  year                              dimension  struggling_index
              Austria  2020 (Urban/Rural?) A small town or village         45.447666
              Croatia  2020 (Urban/Rural?) A small town or village         43.946171
               Cyprus  2020 (Urban/Rural?) A small town or village         53.873581
                Italy  2020 (Urban/Rural?) A small town or village         62.569302
          New Zealand  2020 (Urban/Rural?) A small town or village         41.286366
-       - Removed values: 51 / 1352 (3.77%)
              country  year                              dimension  struggling_index
              Austria  2020 (Urban/Rural?) A small town or villAge         45.447666
              Croatia  2020 (Urban/Rural?) A small town or villAge         43.946171
               Cyprus  2020 (Urban/Rural?) A small town or villAge         53.873581
                Italy  2020 (Urban/Rural?) A small town or villAge         62.569302
          New Zealand  2020 (Urban/Rural?) A small town or villAge         41.286366
    ~ Column suffering_index (new data, changed data)
+       + New values: 51 / 1352 (3.77%)
              country  year                              dimension  suffering_index
              Austria  2020 (Urban/Rural?) A small town or village         0.952936
              Croatia  2020 (Urban/Rural?) A small town or village         11.14745
               Cyprus  2020 (Urban/Rural?) A small town or village        10.192031
                Italy  2020 (Urban/Rural?) A small town or village         4.934379
          New Zealand  2020 (Urban/Rural?) A small town or village         3.807985
-       - Removed values: 51 / 1352 (3.77%)
              country  year                              dimension  suffering_index
              Austria  2020 (Urban/Rural?) A small town or villAge         0.952936
              Croatia  2020 (Urban/Rural?) A small town or villAge         11.14745
               Cyprus  2020 (Urban/Rural?) A small town or villAge        10.192031
                Italy  2020 (Urban/Rural?) A small town or villAge         4.934379
          New Zealand  2020 (Urban/Rural?) A small town or villAge         3.807985
    ~ Column thriving_index (new data, changed data)
+       + New values: 51 / 1352 (3.77%)
              country  year                              dimension  thriving_index
              Austria  2020 (Urban/Rural?) A small town or village         53.5994
              Croatia  2020 (Urban/Rural?) A small town or village        44.90638
               Cyprus  2020 (Urban/Rural?) A small town or village       35.934387
                Italy  2020 (Urban/Rural?) A small town or village       32.496323
          New Zealand  2020 (Urban/Rural?) A small town or village       54.905647
-       - Removed values: 51 / 1352 (3.77%)
              country  year                              dimension  thriving_index
              Austria  2020 (Urban/Rural?) A small town or villAge         53.5994
              Croatia  2020 (Urban/Rural?) A small town or villAge        44.90638
               Cyprus  2020 (Urban/Rural?) A small town or villAge       35.934387
                Italy  2020 (Urban/Rural?) A small town or villAge       32.496323
          New Zealand  2020 (Urban/Rural?) A small town or villAge       54.905647
= Dataset garden/tuberculosis/2023-11-27/outcomes_disagg
  = Table outcomes_disagg
    ~ Column tsr (changed data)
        ~ Changed values: 243 / 1929 (12.60%)
                                country  year age_group sex cohort_type   tsr -      tsr +
          Upper-middle-income countries  2015      0-14   a      newrel 83.0000  82.977608
          Upper-middle-income countries  2019      0-14   a      newrel 84.4375  84.418114
                                   Asia  2019         a   m      newrel 86.0000  86.013664
                                Oceania  2019         a   m      newrel 71.8750  71.868942
                                 Uganda  2020         a   a      newrel 85.4375  85.417595
= Dataset garden/who/2024-07-26/mortality_database
  = Table mortality_database
    ~ Column age_standardized_death_rate_per_100_000_standard_population (changed metadata)
+       + title: |-
-       - title: Age-standardized deaths from << cause.lower() >> in << sex.lower() >> per 100,000 people
        ? ^^^^^^
+       +   Age-standardized deaths from << cause.lower() >> in << sex.lower() >> in those aged << age_group.lower() >> per 100,000 people
        ? ^                                                                      ++++++++++++++++++++++++++++++++++++++
-       - description_short: Reported deaths from << cause.lower() >> in << sex.lower() >> per 100,000 people.
        ?                                                                                     ----------------
+       + description_short: Reported deaths from << cause.lower() >> in << sex.lower() >> in those aged << age_group.lower() >> per
        ?                                                                                 ++++++++++++++++++++++++++++++++++++++
+       +   100,000 people.
= Dataset garden/who/2024-08-06/mortality_database_cancer
  = Table mortality_database_cancer
    ~ Column age_standardized_death_rate_per_100_000_standard_population (changed metadata)
+       + title: |-
-       - title: Age-standardized deaths from << cause.lower() >> in << sex.lower() >> per 100,000 people
        ? ^^^^^^
+       +   Age-standardized deaths from << cause.lower() >> in << sex.lower() >> in those aged << age_group.lower() >> per 100,000 people
        ? ^                                                                      ++++++++++++++++++++++++++++++++++++++
-       - description_short: Reported deaths from << cause.lower() >> in << sex.lower() >> per 100,000 people.
        ?                                                                                     ----------------
+       + description_short: Reported deaths from << cause.lower() >> in << sex.lower() >> in those aged << age_group.lower() >> per
        ?                                                                                 ++++++++++++++++++++++++++++++++++++++
+       +   100,000 people.


Legend: +New  ~Modified  -Removed  =Identical  Details
Hint: Run this locally with etl diff REMOTE data/ --include yourdataset --verbose --snippet

Automatically updated datasets matching weekly_wildfires|excess_mortality|covid|fluid|flunet|country_profile|garden/ihme_gbd/2019/gbd_risk are not included

Edited: 2024-12-13 08:51:54 UTC
Execution time: 1636.80 seconds

@Marigold Marigold marked this pull request as ready for review December 4, 2024 09:34
@Marigold Marigold requested a review from pabloarosado December 4, 2024 09:35
Copy link
Contributor

@pabloarosado pabloarosado left a comment

Choose a reason for hiding this comment

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

Thanks a lot for fixing this issue so quickly, @Marigold!
This will help align what we have in the owid-catalog and in our friendly data catalog, making the ETL our only source of data again. It will also let us find individual indicators in the catalog by metadata content (which I suppose would not be possible with long formats). And it will streamline the production of mdim steps, avoiding circularity with DB. So I think this is a movement in the right direction.

I understand that, for big tables, there could be performance issues. But we can simply stick to long formats in those cases, as an exception (and maybe we'll figure out a better solution in the future).

etl/helpers.py Outdated Show resolved Hide resolved
@Marigold
Copy link
Collaborator Author

Marigold commented Dec 11, 2024

I've compared performance on time etlr grapher/who/2024-08-06/mortality_database_cancer$ --force --only --grapher (this isn't the largest dimensional dataset by far, but wide format has 4500 indicators which is representative)

long-to-wide

  • data://grapher step takes 101s and produces mortality_database_cancer.meta.json with 19mb and mortality_database_cancer.feather with 37mb
  • grapher://grapher step takes 141s

keeping long format

  • data://grapher step takes 3s and produces mortality_database_cancer.meta.json with 0.4mb and mortality_database_cancer.feather with 30mb
  • grapher://grapher step takes 120s

Converting from long to wide is slower mainly because of saving the feather file. The reason long format is faster even in the grapher:// step is loading of data from disk and inefficient processing of wide format (sparse columns, etc.).

However, when considered overall, it's not a deal-breaker. One advantage of converting to a wide format in the data:// step is that Jinja errors are caught earlier, and we have the flexibility to set metadata for both the long and wide formats.

@pabloarosado
Copy link
Contributor

Thanks a lot for the analysis, @Marigold! My intuition is that we may be able to speed up some of those processes or make exceptions for very wide tables if need be. But overall, I agree with the conclusion. Even if it slows down the run in some cases, it does bring important benefits in most cases (where, if I understand correctly, there is no significant slowdown).
I see that you are still on it, but please let me know if you need help or want to discuss anything, thanks!

@Marigold Marigold merged commit 2876953 into master Dec 13, 2024
9 of 10 checks passed
@Marigold Marigold deleted the long-to-wide branch December 13, 2024 08:47
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