[Python] Use np.nan without importing numpy

Discussão em 'Python' iniciado por Stack, Maio 18, 2025.

  1. Stack

    Stack Membro Participativo

    I am used to replacing empty string with NaN and dropping to remove empty data.

    import pandas as pd
    import numpy as np

    df.replace('', np.nan).dropna()


    However, I want my function to run using serverless framework. I need to import numpy just to use np.nan, which eats up my precious 250MB limit for package size.

    Importing pd.np.nan works, but there is warning that pandas.np module is deprecated and will be removed from a future version of pandas.

    Is there any solution to use np.nan without importing numpy?

    Continue reading...

Compartilhe esta Página