In [1]: import numpy as np In [2]: import pandas as pd In [3]: ser = pd.Series([1, 2, np.nan, 4]) In [4]: pd.isnull(ser) Out[4]: 0 False 1 False 2 True 3 False dtype: bool 请注意,np.nan == np.nan 返回False,因此你应该
pandas 2.0.1 parso 0.8.3 pathos 0.3.0 pickleshare 0.7.5 piexif 1.1.3 pillow 9.5.0 pip 23.1.2 platformdirs 4.0.0 portalocker 2.7.0 pox 0.3.2 ppft 1.7.6.6 prompt-toolkit 3.0.39 protobuf 3.20.0 psutil 5.9.5 pure-eval 0.2.2 py-cpuinfo 9.0.0 pyasn1 0.5.0 pyasn1-modules 0.3.0 ...
def test_feature_name_validation_missing_columns_drop_passthough(): """Test the interaction between {'drop', 'passthrough'} and missing column names.""" pd = pytest.importorskip("pandas") X = np.ones(shape=(3, 4)) df = pd.DataFrame(X, columns=['a', 'b', 'c', 'd']) df_...
To utilize df as a name in your if statement, it is necessary to assign it a value. Suitable empty values includeNoneand a dataframe without any rows. Let's assume the latter option. import pandas df = None for i in range(100): if df is None: # Your default dataframe here. # You...
def test_feature_name_validation_missing_columns_drop_passthough(): """Test the interaction between {'drop', 'passthrough'} and missing column names.""" pd = pytest.importorskip("pandas") X = np.ones(shape=(3, 4)) df = pd.DataFrame(X, columns=['a', 'b', 'c', 'd']) df_...