Title: Bug - cannot convert float NaN to integer in merge_hapi · Issue #4 · hapi-server/tools-python · GitHub
Open Graph Title: Bug - cannot convert float NaN to integer in merge_hapi · Issue #4 · hapi-server/tools-python
X Title: Bug - cannot convert float NaN to integer in merge_hapi · Issue #4 · hapi-server/tools-python
Description: merge_hapi() throws an error when the resulting dataframe contains a column of ints and NaNs because Python does not allow converting NaN to int. Reproduce error: from hapiclient import hapi from hapiplot import hapiplot import hapitools...
Open Graph Description: merge_hapi() throws an error when the resulting dataframe contains a column of ints and NaNs because Python does not allow converting NaN to int. Reproduce error: from hapiclient import hapi from h...
X Description: merge_hapi() throws an error when the resulting dataframe contains a column of ints and NaNs because Python does not allow converting NaN to int. Reproduce error: from hapiclient import hapi from h...
Opengraph URL: https://github.com/hapi-server/tools-python/issues/4
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug - cannot convert float NaN to integer in merge_hapi","articleBody":"merge_hapi() throws an error when the resulting dataframe contains a column of ints and NaNs because Python does not allow converting NaN to int.\r\n\r\nReproduce error:\r\n```python\r\nfrom hapiclient import hapi\r\nfrom hapiplot import hapiplot\r\nimport hapitools\r\n\r\nopts = {'logging': False, 'usecache': True, 'cachedir': './hapicache' }\r\nstart = '2013-01-01T00:00:54Z'\r\nstop = '2013-01-01T06:00:54.000Z'\r\nserverA, datasetA, parametersA = 'https://cdaweb.gsfc.nasa.gov/hapi', 'OMNI2_H0_MRG1HR', 'DST1800'\r\nserverB, datasetB, parametersB = \"https://imag-data.bgs.ac.uk/GIN_V1/hapi\", \"cki/best-avail/PT1M/hdzf\", \"Field_Vector\"\r\n\r\ndataA, metaA = hapi(serverA, datasetA, parametersA, start, stop, **opts)\r\ndataB, metaB = hapi(serverB, datasetB, parametersB, start, stop, **opts)\r\ndataB = dataB[80:100]\r\nnewAB, metaAB = hapitools.merge_hapi(dataA, metaA, dataB, metaB, round_to_sec = True, fill_nan=False)\r\nhapiplot(newAB, metaAB)\r\n```\r\n```\r\n---------------------------------------------------------------------------\r\nValueError Traceback (most recent call last)\r\nCell In[2], [line 14](vscode-notebook-cell:?execution_count=2\u0026line=14)\r\n [12](vscode-notebook-cell:?execution_count=2\u0026line=12) dataB, metaB = hapi(serverB, datasetB, parametersB, start, stop, **opts)\r\n [13](vscode-notebook-cell:?execution_count=2\u0026line=13) dataB = dataB[80:100]\r\n---\u003e [14](vscode-notebook-cell:?execution_count=2\u0026line=14) newAB, metaAB = hapitools.merge_hapi(dataA, metaA, dataB, metaB, round_to_sec = True, fill_nan=False)\r\n [15](vscode-notebook-cell:?execution_count=2\u0026line=15) hapiplot(newAB, metaAB)\r\n\r\nFile ~/GitHub/hapi-server/tools-python/src/hapitools.py:123, in merge_hapi(data1, meta1, data2, meta2, how, round_to_sec, fill_nan)\r\n [121](https://file+.vscode-resource.vscode-cdn.net/Users/tinsmcl1/GitHub/hapi-server/tools-python/~/GitHub/hapi-server/tools-python/src/hapitools.py:121) dt = merge_dtypes(data1, data2, trim='Time')\r\n [122](https://file+.vscode-resource.vscode-cdn.net/Users/tinsmcl1/GitHub/hapi-server/tools-python/~/GitHub/hapi-server/tools-python/src/hapitools.py:122) new_data = new_df.to_records(index=False, column_dtypes={\"Time\": \"S30\"})\r\n--\u003e [123](https://file+.vscode-resource.vscode-cdn.net/Users/tinsmcl1/GitHub/hapi-server/tools-python/~/GitHub/hapi-server/tools-python/src/hapitools.py:123) new_data = np.array([tuple([nparray_unpack_to_list(e) for e in elm]) for elm in new_data], dtype=dt)\r\n [124](https://file+.vscode-resource.vscode-cdn.net/Users/tinsmcl1/GitHub/hapi-server/tools-python/~/GitHub/hapi-server/tools-python/src/hapitools.py:124) new_data = np.array([tuple(i) for i in new_data], dtype=dt)\r\n [126](https://file+.vscode-resource.vscode-cdn.net/Users/tinsmcl1/GitHub/hapi-server/tools-python/~/GitHub/hapi-server/tools-python/src/hapitools.py:126) return new_data, new_meta\r\n\r\nValueError: cannot convert float NaN to integer\r\n```\r\n","author":{"url":"https://github.com/tinsmcl1","@type":"Person","name":"tinsmcl1"},"datePublished":"2024-07-31T15:46:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/4/tools-python/issues/4"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fb203a93-0582-637d-3a10-61fbae22d8b9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 811C:135B7:F6D24F:14F8047:6A4DD5A8 |
| html-safe-nonce | a0994b6e4b1350daffdde6a8d630a091270db6a7859bd5833b272ef4f7b26024 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTFDOjEzNUI3OkY2RDI0RjoxNEY4MDQ3OjZBNERENUE4IiwidmlzaXRvcl9pZCI6IjI3NTkxNzc5ODU5MTEwMTg5MjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 98dadc5b399f9addeb8341ce17bbe9fc84d183541faa5e2d7bc09213e464e888 |
| hovercard-subject-tag | issue:2440372894 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/hapi-server/tools-python/4/issue_layout |
| twitter:image | https://opengraph.githubassets.com/de1538b441a8be12034295072ae06257cbbdb1b17a4b3703c48797fd5c8434d4/hapi-server/tools-python/issues/4 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/de1538b441a8be12034295072ae06257cbbdb1b17a4b3703c48797fd5c8434d4/hapi-server/tools-python/issues/4 |
| og:image:alt | merge_hapi() throws an error when the resulting dataframe contains a column of ints and NaNs because Python does not allow converting NaN to int. Reproduce error: from hapiclient import hapi from h... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tinsmcl1 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/hapi-server/tools-python git https://github.com/hapi-server/tools-python.git |
| octolytics-dimension-user_id | 22482204 |
| octolytics-dimension-user_login | hapi-server |
| octolytics-dimension-repository_id | 825902843 |
| octolytics-dimension-repository_nwo | hapi-server/tools-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 825902843 |
| octolytics-dimension-repository_network_root_nwo | hapi-server/tools-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width