Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] DuckDB -> Pandas | NULL -> str becomes None instead of 'NaN' #8745

Merged
merged 7 commits into from
Sep 4, 2023

Conversation

Tishj
Copy link
Contributor

@Tishj Tishj commented Aug 31, 2023

This PR fixes #8652 and a bunch of others that raise the same issue.

Changes made:
Separated the giant file array_wrapper.cpp and array_wrapper.hpp into:
raw_array_wrapper, array_wrapper and numpy_result_conversion

Bundled all parameters used in the internal functions of ArrayWrapper::Append into NumpyAppendData.

changed NUMPY_T NullValue<class NUMPY_T>() to:
NUMPY_T NullValue<class NUMPY_T, bool PANDAS>(bool &set_mask)

This allows the NullValue function to be in charge of whether the mask gets set, and change behavior based on if PANDAS is set or not.

The only NullValue that has been changed for now is StringConvert, it's now:

	template <class NUMPY_T, bool PANDAS>
	static NUMPY_T NullValue(bool &set_mask) {
		if (PANDAS) {
			set_mask = false;
			return Py_None;
		}
		set_mask = true;
		return nullptr;
	}

The NumpyResultConversion has a new constructor parameter, bool pandas = false.
This gets forwarded to the ArrayWrapper created on construction.

@github-actions github-actions bot marked this pull request as draft August 31, 2023 14:27
@Tishj Tishj marked this pull request as ready for review September 2, 2023 16:32
@Mytherin Mytherin merged commit f2bf8d9 into duckdb:main Sep 4, 2023
15 checks passed
@Mytherin
Copy link
Collaborator

Mytherin commented Sep 4, 2023

Thanks! LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exporting string columns to pandas gives NaNs for NULL values
2 participants