I think you are correct.
Basically I am trying to sum up imports when Hs_code starts with 08.
Does anyone know how I can do a slice on the first two digits of the int column (HS_code) and if those first two number = 02 then sum up imports_vfd.
Thanks for any help
Thanks scidam - your one worked. You'd think this would be a common issue and you could find the answer online easier :'(
Basically I am trying to sum up imports when Hs_code starts with 08.
data.loc[data.Hs_code.str[:2] == '08'].Imports_vfd.sum()This code
data['Hs_code'] = f"{data['Hs_code']}"converted it to a string but put an array of numbers in each input.
Does anyone know how I can do a slice on the first two digits of the int column (HS_code) and if those first two number = 02 then sum up imports_vfd.
Thanks for any help
Thanks scidam - your one worked. You'd think this would be a common issue and you could find the answer online easier :'(