-3
I’m having a problem with my code,I get an xlsx file, and I do the whole procedure correctly. but the file comes with some commas that need to be removed, and when I do the if to check if it has the comma it does not recognize and does not perform my conditional structure, and if there is no comma I do not want you to do anything, someone can help me where I am missing.
def main(bi):
// Essa tabela possui virgula, mas ele não entra nessa condição abaixo
if bi['Localizador [Outros, Aéreo, Cruise]'] == ',':
bi['A'] = bi['Localizador [Outros, Aéreo,Cruise]'].str.split(',').str[0]
bi['A'].fillna("null", inplace=True)
def f(bi):
if bi['A'] == "null":
val = bi['Localizador [Outros, Aéreo, Cruise]']
else:
val = bi['A']
return val
bi['B'] = bi.apply(f, axis=1)
bi['Localizador [Outros, Aéreo, Cruise]'] = bi['B']
del bi['A']
del bi['B']
else:
bi['Localizador [Outros, Aéreo, Cruise]']
Could exemplify a part of that xlsx file ?
– Absolver
is a common xml file, which I turn into a string and then into a DF. This column comes some numbers(Ex: 123456,123456,123456) when I select the split without the if it rotates normally and the column goes like this (Ex : '123456'), but when I do the if checking if it has comma in the column, it does not enter the split even containing comma
– Manoel
You would then have to check if the string has a comma, and the way it is, vc is checking if the string(column content) is only a string
– Absolver
I think you meant something like that ( if "," in bi['Finder [Others, Aerial, Cruise]']: but it didn’t work either
– Manoel
You can provide a sample of your data, and adapt the question so that it has an example minimum, complete and verifiable of the problem?
– Terry