[Python] is there a way to assign a numpy array into pandas without a copy?

Discussão em 'Python' iniciado por Stack, Junho 27, 2025.

  1. Stack

    Stack Membro Participativo

    I'm in a performance critical field, where we store our results in pandas dataframes - issue is we are doing most of computations in numpy and then assigning to pd later - but this forces a copy on assign: df['col'] = arr # this will create a copy

    My quesiton: is there a pandas friendly way to assign in a way that will not break in the future? Is this feature in the pipeline? I currently found df._set_item_mgr('col', arr) but am wary of potential changes in the future.

    I was thinking of making an issue on GH, but wanted to see what everyone thinks before submitting :)

    Continue reading...

Compartilhe esta Página