aws / aws/amazon-redshift-python-driver

pandas None/NaN mappings

Open
#251 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
220
Forks
86
PR merge metrics
No merged PRs in 30d

Description

I'm using `write_dataframe` function to write a pandas DataFrame. My context is that this dataframe containts columns of three different types:

1. Object (string) in pandas has None as missing data
2. Int64 in pandas has np.nan as missing data
3. Floats64 in pandas has np.nan as missing data

When writing to Redshift, these values are converted as such:

- None as NULL using varchar(20) with bytedict encoding
- NaN as -9223372036854775808 using BIGINT with az64 encoding
- NaN as "NaN" using DOUBLE PRECISION with RAW encoding

When I try to query using SQL, based on the column, I have to filter with:

1. IS NULL
2. = -9223372036854775808
3. ::text = "NaN"

Is this intended? I wish to map all None/NaN values of pandas into NULL values. Is this possible?

Contributor guide

Open the contributing guide

Research direction

Start at the write_dataframe entry point and reproduce the issue with object, nullable Int64, and float64 pandas columns containing None or NaN. Trace how each missing value is converted before it reaches Redshift; done means the behavior is consistent with the intended mapping to NULL, with coverage for the three reported column types.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, pandas, python, sql
Domain
data, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.