How to handle 'NaN' Values in Dataframe




I have requirement that- Import data from one excel to another application

  1. I have imported the data to dataframe.
  2. putting each cell data to application using REST API.
  3. when I dont have any data in excel - the data frame has the value ‘NaN’

while running my code it says -

{“statusCode”:400,“titleMessage”:“Bad Request”,“helpMessage”:“Please correct the input object”,“userMessage”:“There was an error while processing JSON content. The original message was: ‘Non-standard token ‘NaN’: enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow\n at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@44c37792; line: 1, column: 116]’”}

After that I have used fillna(" ")
it throws error:
{“statusCode”:400,“titleMessage”:“Value not allowed”,“userMessage”:“The numeric attribute ‘’ has an invalid value ({1}).”,“errorCode”:“attDoubleValueInvalid”}

Can Somebody help me out here.



Hi Sachin, could you share your code?

df=pd.read_excel("Column Import Template.xlsx")
#df = df.fillna("")
#df_json = json.loads(df1)

#print df.Name

for index, row in df.iterrows():

# Call REST API POST method to Add  Asset
payload = {
headers  = {"Content-Type": "application/json"}
from requests.auth import HTTPBasicAuth'URL, auth=HTTPBasicAuth('User', 'password'),headers=headers, data=json.dumps(payload))
            #Converting Data to Json Format
            #Call The REST API to Add Attributes of Asset 
payloadAttributes =   [
"assetId": resp['id'],
"typeId": "00000000-0000-0000-0000-000000003114",
"value":  row['Description']
"assetId": resp['id'],
"typeId": "714853d0-b124-48ff-ae69-6ab5ce3b3037",
"value":  row['Column Name']
"assetId": resp['id'],
"typeId": "00000000-0000-0000-0000-000000000245",
"value": row['Max Length']
            #headers  = {"Content-Type": "application/json"}
            #from requests.auth import HTTPBasicAuth
          'uRL', auth=HTTPBasicAuth('User', 'PaSS'),headers=headers, data=json.dumps(payloadAttributes))


@ pjoshi15 - have added the code.Please check


@sachin123456 Which part of the code is throwing error? If you could share the data as well, then I or anyone from the community could find the issue with much more ease.


@sachin123456 fillna() with “null”

df = df.fillna(“null”)