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

Sector_profile indicator do not output isic_4digit column at product level. #634

Closed
kalashsinghal opened this issue Dec 4, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@kalashsinghal
Copy link
Collaborator

kalashsinghal commented Dec 4, 2023

Dear @maurolepore

I noticed that the final output from Sector_profile do not output the isic_4digit column. Please have a look at the reprex:

library(dplyr)
library(readr)

sp_comp <- read_csv("/path/sector_profile_companies.csv") |>
    slice(1:100)
  
sp_scenario <- read_csv("/path/sector_profile_any_scenarios.csv")

profile <- tiltIndicator::sector_profile(sp_comp, sp_scenario) |> tiltIndicator::unnest_product()
profile
#> # A tibble: 140 × 11
#>    companies_id               grouped_by risk_category profile_ranking clustered
#>    <chr>                      <chr>      <chr>                   <dbl> <chr>    
#>  1 %ef%bb%bfmathias-maschine… ipr_1.5c … medium                   0.13 forming  
#>  2 %ef%bb%bfmathias-maschine… ipr_1.5c … high                     0.8  forming  
#>  3 %ef%bb%bfmathias-maschine… weo_nz 20… medium                   0.22 forming  
#>  4 %ef%bb%bfmathias-maschine… weo_nz 20… high                     0.96 forming  
#>  5 %ef%bb%bfmathias-maschine… ipr_1.5c … medium                   0.22 hand too…
#>  6 %ef%bb%bfmathias-maschine… ipr_1.5c … high                     0.96 hand too…
#>  7 %ef%bb%bfmathias-maschine… weo_nz 20… high                     0.23 hand too…
#>  8 %ef%bb%bfmathias-maschine… weo_nz 20… high                     0.94 hand too…
#>  9 %ef%bb%bfmathias-maschine… ipr_1.5c … low                      0.09 machining
#> 10 %ef%bb%bfmathias-maschine… ipr_1.5c … high                     0.95 machining
#> # ℹ 130 more rows
#> # ℹ 6 more variables: activity_uuid_product_uuid <chr>, tilt_sector <chr>,
#> #   scenario <chr>, year <dbl>, type <chr>, tilt_subsector <chr>

Created on 2023-12-04 with reprex v2.0.2

Please add this column for both sector_profile and sector_profile_upstream indicators at product level. Thanks!

@kalashsinghal kalashsinghal added the bug Something isn't working label Dec 4, 2023
@maurolepore
Copy link
Contributor

maurolepore commented Dec 4, 2023

@kalashsinghal

I think the feature you want is already implemented in tiltIndicatorAfter, right?

This reprex comes from the helpfile of tiltIndicatorAfter::profile_sector() and the output at product level does include the column isic_4digit.

library(tiltToyData)
library(tiltIndicator)
library(tiltIndicatorAfter)
library(dplyr, warn.conflicts = FALSE)
library(readr, warn.conflicts = FALSE)

options(readr.show_col_types = FALSE)

companies <- read_csv(toy_sector_profile_companies())
scenarios <- read_csv(toy_sector_profile_any_scenarios())

result <- profile_sector(
  companies,
  scenarios,
  # TODO: Move to tiltToyData
  europages_companies = ep_companies |> head(3),
  ecoinvent_activities = ecoinvent_activities |> head(3),
  ecoinvent_europages = matches_mapper |> head(3)
)

result |> 
  unnest_product() |> 
  relocate(matches("isic"))
#> # A tibble: 196 × 27
#>    isic_4digit companies_id     company_name country PSTR_risk_category scenario
#>          <dbl> <chr>            <chr>        <chr>   <chr>              <chr>   
#>  1        2410 fleischerei-sti… <NA>         <NA>    high               IPR 1.5…
#>  2        2410 fleischerei-sti… <NA>         <NA>    high               IPR 1.5…
#>  3        2410 fleischerei-sti… <NA>         <NA>    low                stated …
#>  4        2410 fleischerei-sti… <NA>         <NA>    low                announc…
#>  5        2410 fleischerei-sti… <NA>         <NA>    low                net zer…
#>  6        2410 fleischerei-sti… <NA>         <NA>    low                stated …
#>  7        2410 fleischerei-sti… <NA>         <NA>    low                announc…
#>  8        2410 fleischerei-sti… <NA>         <NA>    high               net zer…
#>  9        2410 fleischerei-sti… <NA>         <NA>    low                stated …
#> 10        2410 fleischerei-sti… <NA>         <NA>    medium             announc…
#> # ℹ 186 more rows
#> # ℹ 21 more variables: year <dbl>, ep_product <chr>,
#> #   matched_activity_name <chr>, matched_reference_product <chr>, unit <chr>,
#> #   tilt_sector <chr>, tilt_subsector <chr>, multi_match <lgl>,
#> #   matching_certainty <chr>, matching_certainty_company_average <chr>,
#> #   company_city <chr>, postcode <dbl>, address <chr>, main_activity <chr>,
#> #   activity_uuid_product_uuid <chr>, profile_ranking <dbl>, …

Created on 2023-12-04 with reprex v2.0.2

@maurolepore
Copy link
Contributor

BTW, this duplicates #631 (comment).
I'm closing but if you can continue the conversation. If necessary I can reopen.

@maurolepore maurolepore closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2023
@kalashsinghal
Copy link
Collaborator Author

kalashsinghal commented Dec 4, 2023

@maurolepore Apologies! I forgot that this column was added through the companies and product datasets for both indicators in tiltIndicatorAfter. Thanks for closing!

@maurolepore
Copy link
Contributor

maurolepore commented Dec 4, 2023

Remember tiltIndicatorAfter wraps tiltIndicator. So tiltIndicator should not be called directly. If you're working on workflow files, all you need is the new API of tiltIndicatorAfter -- i.e. the profile*() functions.

https://2degreesinvesting.github.io/tiltIndicatorAfter/reference/index.html

From the changelog

New API wraps titlIndicator and outputs columns matching isic and sector (#78).

@kalashsinghal
Copy link
Collaborator Author

@maurolepore Thanks for mentioning this! I will use them instead :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants