2
Good evening Gentlemen, I have the following Dataframe, imported from an xlsx.
NUM_LEGISLACAO DSC_URL COD_SITUACAO ... DSC_TIPO num ano
264 89.272/1984 NaN 2.0 ... NORMATIVO 89.272 1984
265 90.396/1984 NaN 11.0 ... NORMATIVO 90.396 1984
266 90.804/1985 NaN 2.0 ... CONCRETO 90.804 1985
267 81195/1978 NaN NaN ... NaN 81195 1978
268 5475/1905 NaN NaN ... NaN 05475 1905
269 90.396/1984 NaN 11.0 ... NORMATIVO 90.396-A 1984
I imported with the code below:
df1 = pd.read_excel(file01, sheet_name='Exportar Planilha')
df1['num'], df1['ano'] = df1['NUM_LEGISLACAO'].str.split('/').str
#notok
#substitui '.' e '-' no campo 'num'
df1['num'] = df1.num.str.replace('[\.-]', '')
#formata com 5 digitos
df1.num = df1.num.astype(str).str.rjust(5, '0')
df1['num'] = df1.num.astype(str).str.zfill(5)
I intend to remove '.' from the 'num' field and produce the following result:
NUM_LEGISLACAO DSC_URL COD_SITUACAO ... DSC_TIPO num ano
264 89.272/1984 NaN 2.0 ... NORMATIVO 89272 1984
265 90.396/1984 NaN 11.0 ... NORMATIVO 90396 1984
269 90.396/1984 NaN 11.0 ... NORMATIVO 90396A 1984
However my code does not work and presents the following error:
Typeerror: Type aliases cannot be used with isinstance().
In CSV works: https://repl.it/repls/VerticalDarksalmonMicroscope
– NoobSaibot