Below is the dataframe. PIC_1 and Wgt are strings and p.lgth and p_lgth are integers. If p_lgth is not equal to 30, I want to find 42 in PIC_1 and grab 42 and the 15 digits that come after it.
PIC_1 Wgt p.lgth p_lgth
**PARTIAL-DECODE***P / 42011721930018984390078... 112 53 53
So the output from above should be 42011721930018984
My code that does not work follows:
def pic_mod(row):
if row['p_lgth'] !=30:
PIC_loc = row['PIC_1'].find('42')
PIC_2 = row['PIC_1'].str[PIC_loc:PIC_loc + 15]
elif row['p_lgth']==30:
PIC_2=PIC_1
return PIC_2
row_1 is just a row from the larger df that is identical to the example row given above
row_1 = df71[2:3]
pic_mod(row_1)
ValueError: The truth value of a Series is ambiguous. Use a.empty,
a.bool (), a.item(), a.any() or a.all().
I did type() on the variables and got
type(df71['PIC_1']) = pandas.core.series.Series
type(df71['p_lgth']) = pandas.core.series.Series
type(df71['Wgt']) = pandas.core.series.Series
I'm fairly new to Python. Should these data types come back as int and str? df71 is a df.