Solved

Unexpected error: ValueError: Out of range float values are not JSON compliant. Make sure your data does not contain NaN(s) or +/- Inf!

  • 15 April 2024
  • 3 replies
  • 58 views

Badge

Doing the ‘hands-on’ for Data Engineer Basics - “Learn to Use the Cognite Python SDK “ Course."

I have done the following:

  1. Make a dataframe from reading from a csv file:

    One of the columns in the csv file is ‘region’. The 5 different values in the region column are 

    When the above code is run, the  following appears on the screen:

    Q1. Does this mean pandas has interpreted the region “None” as “nan”?

If so that would explain why the following code throws “ValueError: Out of range float values are not JSON compliant. Make sure your data does not contain NaN(s) or +/- Inf!” 

 

I would value your guidance as I have not worked with pandas() much at all.

Thank you,

Doug

 

 

icon

Best answer by Mugless Durry 18 April 2024, 03:15

View original

3 replies

Badge

OK, I replaced “None” with “Antarctica” in the ‘region’ column of the csv file.

Then, 

 

This does not help. The same error results.

 

oh dear!

Can anyone help?

Thanks.

Doug

Userlevel 3
Badge +6

Hi! I tried this myself and I don’t get any error.

I see that you have replaced the data_set_id and root_asset.id variable with the actual data set id and the root asset id. Could this cause any issues, anything mixed up?

 

# Create each region as a new asset
store = []
for region in df['region'].unique():
asset=Asset(name=region, data_set_id=data_set_id,parent_id=root_asset.id)
store.append(asset)

client.assets.create(store)

 

Badge

Thanks Sofie, for your reply.

Suddenly, without me doing anything, the issue went away.

I do not know what is going on.

Reply