File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 1111
1212from pandas_openscm .exceptions import MissingOptionalDependencyError
1313from pandas_openscm .index_manipulation import set_index_levels_func
14- from pandas_openscm .indexing import multi_index_match
14+ from pandas_openscm .indexing import multi_index_lookup , multi_index_match
1515
1616if TYPE_CHECKING :
1717 import pint .facets
@@ -107,10 +107,14 @@ def convert_unit_from_target_series(
107107 df_reset_unit = df .reset_index (unit_level )
108108 df_units = df_reset_unit [unit_level ].rename ("df_unit" )
109109
110+ desired_unit_in_df = multi_index_lookup (desired_unit , df_units .index ).rename (
111+ "target_unit"
112+ )
113+
110114 # Don't need to align, pandas does that for us.
111115 # If you want to check, compare the below with
112116 # unit_map = pd.DataFrame([df_units_s, target_units_s.sample(frac=1)]).T
113- unit_map = pd .DataFrame ([df_units , desired_unit . rename ( "target_unit" ) ]).T
117+ unit_map = pd .DataFrame ([df_units , desired_unit_in_df ]).T
114118
115119 unit_map_no_change = unit_map ["df_unit" ] == unit_map ["target_unit" ]
116120 if unit_map_no_change .all ():
You can’t perform that action at this time.
0 commit comments