Skip to main content
Solved

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

  • April 15, 2024
  • 3 replies
  • 119 views

Forum|alt.badge.img+4

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

 

 

Best answer by Mugless Durry

Thanks Sofie, for your reply.

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

I do not know what is going on.

View original
Did this topic help you find an answer to your question?

3 replies

Forum|alt.badge.img+4
  • Author
  • Seasoned
  • 9 replies
  • April 15, 2024

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


Sofie Haug
Practitioner
Forum|alt.badge.img+7
  • Cognite Academy Instructor
  • 151 replies
  • April 16, 2024

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)

 


Forum|alt.badge.img+4
  • Author
  • Seasoned
  • 9 replies
  • Answer
  • April 18, 2024

Thanks Sofie, for your reply.

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

I do not know what is going on.


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings