Condition for file name

Asked

Viewed 17 times

0

I need to make the following condition if the file name, which is a . json, has the characters VG, AP or GM pandas:

    if name_arquivo.str.contains('_VG_') or name_arquivo.str.contains('_AP_') or name_arquivo.str.contains('_GM_'):
         df_s3['PremioTotal'] = df_s3.apply(
            lambda x: [coberturas['PremioTotal'] for coberturas in x.Coberturas], 
            axis=1, 
            result_type='expand')

But I’m getting the following error:

Attributeerror: str Object has no attribute 'str'

Can someone help me, please?

  • Little information to answer the question. Just an assumption: The variable name_arquivo must be of the string type. Thus if should be if "_VG_" in name_arquivo or "_AP_" in name_arquivo or "_GM_" in name_arquivo:

  • It didn’t work. The problem is this: in the files that have these letters in the names, I need to open an array to take out the Total Prize field, which is in the Covers column. For the other files, this field is already available, without having to extract. All the files are in the same folder.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.