question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dataset download fails when reading boolean column with nulls

See original GitHub issue

Reproducible code:

from cartoframes.auth import set_default_context
from cartoframes import Dataset

set_default_context(
    base_url='https://eschbacher.carto.com',
    api_key='default_public'
)

df = Dataset.from_table('seattle_collisions').download()
StackTrace --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-33-30c7f7d520dd> in <module> ----> 1 df = Dataset.from_table('seattle_collisions').download()

~/git/CartoDB/cartoframes/cartoframes/dataset.py in download(self, limit, decode_geom, retry_times) 131 table_columns = self.get_table_columns() 132 query = self._get_read_query(table_columns, limit) –> 133 self.df = self.cc.fetch(query, decode_geom=decode_geom) 134 return self.df 135

~/git/CartoDB/cartoframes/cartoframes/context.py in fetch(self, query, decode_geom) 525 false_values=[‘f’], 526 index_col=‘cartodb_id’ if ‘cartodb_id’ in df_types else False, –> 527 converters={‘the_geom’: lambda x: _decode_geom(x) if decode_geom else x}) 528 529 if decode_geom:

~/.local/share/virtualenvs/cartoframes-pRWzcuWT/lib/python3.7/site-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision) 700 skip_blank_lines=skip_blank_lines) 701 –> 702 return _read(filepath_or_buffer, kwds) 703 704 parser_f.name = name

~/.local/share/virtualenvs/cartoframes-pRWzcuWT/lib/python3.7/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds) 433 434 try: –> 435 data = parser.read(nrows) 436 finally: 437 parser.close()

~/.local/share/virtualenvs/cartoframes-pRWzcuWT/lib/python3.7/site-packages/pandas/io/parsers.py in read(self, nrows) 1137 def read(self, nrows=None): 1138 nrows = _validate_integer(‘nrows’, nrows) -> 1139 ret = self._engine.read(nrows) 1140 1141 # May alter columns / col_dict

~/.local/share/virtualenvs/cartoframes-pRWzcuWT/lib/python3.7/site-packages/pandas/io/parsers.py in read(self, nrows) 1993 def read(self, nrows=None): 1994 try: -> 1995 data = self._reader.read(nrows) 1996 except StopIteration: 1997 if self._first_chunk:

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.read()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_low_memory()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_rows()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._convert_column_data()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._convert_tokens()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._convert_with_dtype()

ValueError: Bool column has NA values in column 28

Not sure of the cause yet, but I have a feeling that pandas bool columns cannot have null values.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
Jesus89commented, Jun 11, 2019

Hi @andy-esch,

I have created here a PoC with the implementation of the solution: https://github.com/CartoDB/cartoframes/pull/760. It would be nice if you can try it 😃

0reactions
Jesus89commented, Jun 12, 2019

Fixed in #760

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Nullable NaN. When NA is not False.
Problem : When transforming selected columns to bool, all rows evaluate to either all True or all False and returns a bad headache....
Read more >
Should I store False as Null in a boolean database field?
Is there anything inherently wrong with just storing false as null? Yes. If so can you please explain what the down side should...
Read more >
Entity Framework Core: `SqlNullValueException: Data is Null ...
The error message indicates that EF Core is trying to read string value for a required property, i.e. a property which should never...
Read more >
SQL Boolean Not Recognized - Power Platform Community
Solved: Hello, Scenario: SQL Data Source with Boolean data type in one column Gallery displaying SQL table data Using an IF statement to...
Read more >
Problems with adding NOT NULL columns or making nullable ...
This can happen when you try to add a new column that can't accept NULL values, or to change an existing, nullable column...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found