Skip to content

sqlite3 - significant digits #34

@BuildWithData

Description

@BuildWithData

for some reason sqlite fails to round to 2 decimal digits sometimes, for example:

    select * from inflows_btc_bxfill
    
    +------------+-------------------+
    |  ref_date  |       TOTAL       |
    +------------+-------------------+
    | 2024-01-11 | 13796.2           |
    | 2024-01-12 | 4023.2            |
    | 2024-01-15 |                   |
    | 2024-01-16 | -1947.1           |
    | 2024-01-17 | 9256.8            |
    | 2024-01-18 | -4514.5           |
    | 2024-01-19 | -545.900000000002 |
    | 2024-01-22 | -2350.3           |

but it seems this is kinda random, for example inflows_btc_bfill is created with data from inflows_btc but:

  select total from inflows_btc_bfill where ref_date = '2024-03-22'

  +---------+
  |  TOTAL  |
  +---------+
  | -310.93 |
  +---------+

  select total from inflows_btc where ref_date = '2024-03-22'

  +-------------------+
  |       TOTAL       |
  +-------------------+
  | -310.929999999999 |
  +-------------------+

but what is weirder is that rounding is done in both cases:

out["TOTAL"] = out.iloc[:, :-1].sum(axis=1).round(2)

out = (extracted.iloc[:, 1:] - extracted.iloc[:, 1:].shift(1)).round(2)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions