issue_comments: 411385081
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/pydata/xarray/issues/2304#issuecomment-411385081 | https://api.github.com/repos/pydata/xarray/issues/2304 | 411385081 | MDEyOklzc3VlQ29tbWVudDQxMTM4NTA4MQ== | 1492047 | 2018-08-08T12:18:02Z | 2018-08-22T07:14:58Z | CONTRIBUTOR | So, a more complete example showing this problem. NetCDF file used in the example : test.nc.zip ````python from netCDF4 import Dataset import xarray as xr import numpy as np import pandas as pd d = Dataset("test.nc") v = d.variables['var'] print(v) <class 'netCDF4._netCDF4.Variable'>int16 var(idx)_FillValue: 32767scale_factor: 0.01unlimited dimensions:current shape = (2,)filling ondf_nc = pd.DataFrame(data={'var': v[:]}) print(df_nc) var0 21.941 27.04ds = xr.open_dataset("test.nc") df_xr = ds['var'].to_dataframe() Comparing both dataframes with float32 precision (1e-6)mask = np.isclose(df_nc['var'], df_xr['var'], rtol=0, atol=1e-6) print(mask) [False True]print(df_xr) varidx0 21.9399991 27.039999Changing the type and rounding the xarray dataframedf_xr2 = df_xr.astype(np.float64).round(int(np.ceil(-np.log10(ds['var'].encoding['scale_factor'])))) mask = np.isclose(df_nc['var'], df_xr2['var'], rtol=0, atol=1e-6) print(mask) [ True True]print(df_xr2) varidx0 21.941 27.04```` As you can see, the problem appears early in the process (not related to the way data are stored in parquet later on) and yes, rounding values does solve it. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
343659822 |