0
Good morning ! I’m new in python and I’m trying to build a script that deletes some lines and includes a column in a dataframe only that for some reason I can’t understand it returns this error.
import pandas as pd
df = pd.read_excel('planilha.xlsx, sheet_name=1)
df = df.drop(['ID EMPRESA', 'NF 2', 'VALOR NF 2', 'VAT'], axis=1)
df = df.drop(df[df.TPV == 0.00].index, inplace=True)
df = df.insert(loc=25, column='Crédito BOAC', value=None)
df.head()
removido por seg.
Como eu deveria fazer neste caso?
put in doubt an example of your dataset, but this error is when the object type is
None
. As your dataset to test where the error occurred and why.– lmonferrari
Imonferrari, I edited it
– zorNe
The error happens in the call of
to_excel
, but in your code it is not even used. Are you sure you have put the correct code or it completely?– Woss
By error shows that you are calling a function from an object
None
, probably in the middle of the way something happened to this object that he was likeNone
.– lmonferrari
Woss I had put # in
insert
to see if the rest went, so the mistake was in theto_excel
. Fixed, but error persists rs.– zorNe
Imonferrari, so I understood this too, but I don’t know how to fix it or at what point it happened.
– zorNe
enter all the code and make the data available (you can remove the confidential data if you have it). Anything uploads the data file to some cloud service and posts the link here.
– lmonferrari
In the second
drop
, you definedinplace=True
. This will make thedrop
occurs directly on owndf
, returningNone
. If you want to get the return, remove the parameterinplace
.– Woss
It’s not working. I removed the
inplace=True
but the error persists.– zorNe
Imonferrar, follow the links: script: https://drive.google.com/file/d/1W0OZFMoBOKbS2IxiB3UtySmCMBgJcAlw/view?usp=sharing excel: https://drive.google.com/file/1qV1lxJ0idIo6iI6_FqQayYeUe5Vf9Wmu/view?usp=sharing
– zorNe