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

feat(python): Improve numpy support: conversion of numpy arrays with … #6738

Merged
merged 1 commit into from
Feb 9, 2023

Conversation

ghuls
Copy link
Collaborator

@ghuls ghuls commented Feb 8, 2023

…architecture dependend dtypes to Polars series and support for np.bytes_ arrays to pl.Binary Polars series.

Improve numpy suppport:

  • Add support for converting numpy arrays with numeric dtypes, which are architecture dependend: e.g. np.longlong, np.ulonglong, np.intc, np.uintc, np.longdouble , to Polars series.

    For example on Windows, the following operation changes the dtype of the output array, which then failed to convert to an pl.UInt32 Polars series:

    arr = np.array([2,1,3], dtype=np.uint32)
    (arr % 2).dtype == np.intc
    
  • Rewrite logic for getting the correct Polars dtype when using numpy ufunc, so it does not need to check for the OS it is running on (same architecture dependend dtypes problem).

  • Add support for converting bytes numpy arrays (np.bytes_) to pl.Binary Polars series.

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Feb 8, 2023
@ghuls
Copy link
Collaborator Author

ghuls commented Feb 8, 2023

Closes: #6559

…architecture dependend dtypes to Polars series and support for np.bytes_ arrays to pl.Binary Polars series.

Improve numpy suppport:
  - Add support for converting numpy arrays with numeric dtypes, which
    are architecture dependend:
      e.g. np.longlong, np.ulonglong, np.intc, np.uintc, np.longdouble
    , to Polars series.

    For example on Windows, the following operation changes the dtype
    of the output array, which then failed to convert to an pl.UInt32
    Polars series:

        arr = np.array([2,1,3], dtype=np.uint32)
        (arr % 2).dtype == np.intc

  - Rewrite logic for getting the correct Polars dtype when using
    numpy __ufunc__, so it does not need to check for the OS
    it is running on (same architecture dependend dtypes problem).
  - Add support for converting bytes numpy arrays (np.bytes_) to
    pl.Binary Polars series.
@ghuls ghuls force-pushed the feat_python_improve_numpy_support branch from 6f1a71f to 9388d43 Compare February 9, 2023 08:57
@ritchie46
Copy link
Member

Thank you @ghuls. 🙏

@ritchie46 ritchie46 merged commit d3633fb into pola-rs:master Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants