-
Notifications
You must be signed in to change notification settings - Fork 9
Missing data is converted to Nan, and can't be re-inserted #283
Copy link
Copy link
Closed
Description
Grabbing data from a timeseries and trying to insert it again causes missing data to be converted to nan in the JSON, which then fails with an error that nan data needs to be removed.
cwms.api.init_session(api_root=CDA_API_ROOT, api_key=CDA_API_KEY)
ts = cwms.get_timeseries(ts_id="Black Butte.Stor-Top Con.Inst.~1Day.0.Calc-val", begin=datetime(2025, 10, 1, 0, 0, 0, 0), office_id=OFFICE)
cwms.api.init_session(api_root=CWBI_API_ROOT, api_key=CWBI_API_KEY)
failures = []
print(ts.json)
try:
cwms.store_timeseries(data=cwms.timeseries_df_to_json(ts.df, ts.json["name"], ts.json["units"], OFFICE))
except cwms.ApiError as ex:
print(ex)
print("done"){'begin': '2025-10-01T07:00:00+00:00', 'date-version-type': 'UNVERSIONED', 'end': '2026-03-27T07:00:00+00:00', 'interval': 'PT0S', 'interval-offset': -2147483648, 'name': 'Black Butte.Stor-Top Con.Inst.~1Day.0.Calc-val', 'office-id': 'SPK', 'page': 'MTc1OTMwMjAwMDAwMHx8MTR8fDMwMDAwMA==', 'page-size': 300000, 'time-zone': 'US/Pacific', 'total': 178, 'units': 'ac-ft', 'value-columns': [{'name': 'date-time', 'ordinal': 1, 'datatype': 'java.sql.Timestamp'}, {'name': 'value', 'ordinal': 2, 'datatype': 'java.lang.Double'}, {'name': 'quality-code', 'ordinal': 3, 'datatype': 'int'}], 'values': [[1759302000000, 112252.99658298839, 0], [1759388400000, 110753.85117407732, 0], [1759474800000, 109254.70576516626, 0], [1759561200000, 107755.5603562552, 0], [1759647600000, 106256.41494734414, 0], [1759734000000, 104757.26953843307, 0], [1759820400000, 103258.12412952201, 0], [1759906800000, 101758.97872061095, 0], [1759993200000, 100259.83331169988, 0], [1760079600000, 98760.68790278882, 0], [1760166000000, 97261.54249387776, 0], [1760252400000, 95762.3970849667, 0], [1760338800000, 94263.25167605563, 0], [1760425200000, nan, 5], [1760511600000, nan, 5], [1760598000000, nan, 5], [1760684400000, nan, 5], [1760770800000, nan, 5], [1760857200000, nan, 5], [1760943600000, nan, 5], [1761030000000, nan, 5], [1761116400000, nan, 5], [1761202800000, nan, 5], [1761289200000, nan, 5], [1761375600000, nan, 5], [1761462000000, nan, 5], [1761548400000, nan, 5], [1761634800000, nan, 5], [1761721200000, nan, 5], [1761807600000, 68777.77972456758, 0], [1761894000000, 67278.63431565651, 0], [1761980400000, 65779.48890674545, 0], [1762066800000, nan, 5], [1762156800000, 62781.198088923324, 0], [1762243200000, 61282.05268001227, 0], [1762329600000, 59782.9072711012, 0], [1762416000000, 58283.76186219014, 0], [1762502400000, 56784.61645327907, 0], [1762588800000, 55285.471044368016, 0], [1762675200000, 53786.32563545695, 0], [1762761600000, 52287.18022654589, 0], [1762848000000, 50788.034817634834, 0], [1762934400000, 49288.88940872377, 0], [1763020800000, 47789.7439998127, 0], [1763107200000, 46290.59859090164, 0], [1763193600000, 44791.453181990575, 0], [1763280000000, 43292.30777307951, 0], [1763366400000, 41793.16236416846, 0], [1763452800000, 40294.016955257386, 0], [1763539200000, 38794.87154634633, 0], [1763625600000, 37295.72613743526, 0], [1763712000000, 35796.580728524204, 0], [1763798400000, 34297.435319613134, 0], [1763884800000, 32798.289910702086, 0], [1763971200000, 31299.144501791016, 0], [1764057600000, 29799.999092879956, 0], [1764144000000, 29799.999092879956, 0], [1764230400000, 29799.999092879956, 0], [1764316800000, 29799.999092879956, 0], [1764403200000, 29799.999092879956, 0], [1764489600000, 29799.999092879956, 0], [1764576000000, 29799.999092879956, 0], [1764662400000, 29799.999092879956, 0], [1764748800000, 29799.999092879956, 0], [1764835200000, 29799.999092879956, 0], [1764921600000, 29799.999092879956, 0], [1765008000000, 29799.999092879956, 0], [1765094400000, 29799.999092879956, 0], [1765180800000, 29799.999092879956, 0], [1765267200000, 29799.999092879956, 0], [1765353600000, 29799.999092879956, 0], [1765440000000, 29799.999092879956, 0], [1765526400000, 29799.999092879956, 0], [1765612800000, 29799.999092879956, 0], [1765699200000, 29799.999092879956, 0], [1765785600000, 29799.999092879956, 0], [1765872000000, 29799.999092879956, 0], [1765958400000, 29799.999092879956, 0], [1766044800000, 29799.999092879956, 0], [1766131200000, 29799.999092879956, 0], [1766217600000, 29799.999092879956, 0], [1766304000000, 29799.999092879956, 0], [1766390400000, 29799.999092879956, 0], [1766476800000, 29799.999092879956, 0], [1766563200000, 29799.999092879956, 0], [1766649600000, 29799.999092879956, 0], [1766736000000, 29799.999092879956, 0], [1766822400000, 29799.999092879956, 0], [1766908800000, 29799.999092879956, 0], [1766995200000, 29799.999092879956, 0], [1767081600000, 29799.999092879956, 0], [1767168000000, 29799.999092879956, 0], [1767254400000, 29799.999092879956, 0], [1767340800000, 29799.999092879956, 0], [1767427200000, 29799.999092879956, 0], [1767513600000, 29799.999092879956, 0], [1767600000000, 29799.999092879956, 0], [1767686400000, 22566.122622293708, 0], [1767772800000, 23080.16354266981, 0], [1767859200000, 24858.008102528103, 0], [1767945600000, 26713.26889896686, 0], [1768032000000, 28229.386998327627, 0], [1768118400000, 29799.999092879956, 0], [1768204800000, 29799.999092879956, 0], [1768291200000, 29799.999092879956, 0], [1768377600000, 29799.999092879956, 0], [1768464000000, 29799.999092879956, 0], [1768550400000, 29799.999092879956, 0], [1768636800000, 29799.999092879956, 0], [1768723200000, 29799.999092879956, 0], [1768809600000, 29799.999092879956, 0], [1768896000000, 29799.999092879956, 0], [1768982400000, 29799.999092879956, 0], [1769068800000, 29799.999092879956, 0], [1769155200000, 29799.999092879956, 0], [1769241600000, 29799.999092879956, 0], [1769328000000, 29799.999092879956, 0], [1769414400000, 29799.999092879956, 0], [1769500800000, 29799.999092879956, 0], [1769587200000, 29799.999092879956, 0], [1769673600000, 29799.999092879956, 0], [1769760000000, 29799.999092879956, 0], [1769846400000, 29799.999092879956, 0], [1769932800000, 29799.999092879956, 0], [1770019200000, 29799.999092879956, 0], [1770105600000, 29799.999092879956, 0], [1770192000000, 29799.999092879956, 0], [1770278400000, 29799.999092879956, 0], [1770364800000, 29799.999092879956, 0], [1770451200000, 29799.999092879956, 0], [1770537600000, 29880.617228002582, 0], [1770624000000, 31446.4846811159, 0], [1770710400000, 33051.09218091897, 0], [1770796800000, 34551.74266997018, 0], [1770883200000, 31205.21141455159, 0], [1770969600000, 31884.39283270239, 0], [1771056000000, 33376.03598145632, 0], [1771142400000, 35118.3319232102, 0], [1771228800000, 33155.61137375518, 0], [1771315200000, 34075.43614106646, 0], [1771401600000, 33505.09926754137, 0], [1771488000000, 34343.28357485513, 0], [1771574400000, 34741.102193165054, 0], [1771660800000, 36168.942835323134, 0], [1771747200000, 37858.60691857782, 0], [1771833600000, 38520.96554941635, 0], [1771920000000, 39118.30891774183, 0], [1772006400000, 33786.723392596316, 0], [1772092800000, 34835.15170513789, 0], [1772179200000, 36546.14885107202, 0], [1772265600000, 38456.796288679165, 0], [1772352000000, 40428.71093973219, 0], [1772438400000, 42438.78367350707, 0], [1772524800000, 44467.78717130223, 0], [1772611200000, 46504.872567360384, 0], [1772697600000, 48567.83999343517, 0], [1772784000000, 50639.02592603591, 0], [1772870400000, 52593.60345478023, 0], [1772956800000, nan, 5], [1773039600000, 56463.873863414155, 0], [1773126000000, 58580.722475501876, 0], [1773212400000, 60718.939652400535, 0], [1773298800000, 62883.294873819716, 0], [1773385200000, 64848.35946847971, 0], [1773471600000, 67009.21690924396, 0], [1773558000000, 69208.65426891217, 0], [1773644400000, 71296.57684082142, 0], [1773730800000, 72914.754361664, 0], [1773817200000, 75036.29341150606, 0], [1773903600000, 77183.73954491543, 0], [1773990000000, 79303.88897459135, 0], [1774076400000, 81102.53020952205, 0], [1774162800000, 83303.45248074298, 0], [1774249200000, 85519.17216936234, 0], [1774335600000, 87721.73259508873, 0], [1774422000000, 89868.26839932242, 0], [1774508400000, 92086.02068054935, 0], [1774594800000, 94303.18246074604, 0]]}
Traceback (most recent call last):
File "C:\source\spk-wm-cwbi-jobs\python\copylocations.py", line 184, in <module>
copy_timeseries()
File "C:\source\spk-wm-cwbi-jobs\python\copylocations.py", line 171, in copy_timeseries
cwms.store_timeseries(data=cwms.timeseries_df_to_json(ts.df, ts.json["name"], ts.json["units"], OFFICE))
File "C:\Users\l2edhdto\AppData\Roaming\Python\Python39\site-packages\cwms\timeseries\timeseries.py", line 442, in timeseries_df_to_json
raise ValueError("Null/NaN data must be removed from the dataframe")
ValueError: Null/NaN data must be removed from the dataframe
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels