# copy

import pandas as pd

df = pd.DataFrame({"co1": [1]})


def foo(df):
    df["col2"] = 2


def bar(df):
    df = df.copy()
    foo(df=df)
    print(df)  # df就在原地生效

bar(df=df)


# copy

import pandas as pd

df = pd.DataFrame({"co1": [1]})


def foo(df):
    df["col2"] = 2
    return df


def bar(df):
    df = df.copy()
    df_2 = foo(df=df)
    print(df)  # df still take effect in situ
    print(df is df_2)  # True

bar(df=df)


df == df  # df every unit cell
df == 0  # df every unit cell