This is more of a newbie python question. I have a pandas dataframe tmp_df
, which I slice using 3 datetime inputs as follows to extract different time ranges of data:
tmp_daily_df = tmp_df.loc[idx[daily[1]:daily[2]],:]
tmp_weekly_df = tmp_df.loc[idx[weekly[1]: weekly[2]],:]
tmp_monthly_df = tmp_df.loc[idx[monthly[1]: monthly[2]],:]
Then I pass the resulting 3 dataframes to a function called compute_stats()
, which calculates various statistics and performs some manipulations to the input dataframe (i.e. tmp_daily_df
). One such manipulation is adding several new columns to tmp_daily_df
etc.
final_daily_df = compute_stats(tmp_daily_df, 'M','').reset_index(drop=True)
final_weekly_df = compute_stats(tmp_weekly_df, 'M','').reset_index(drop=True)
final_monthly_df = compute_stats(tmp_monthly_df, 'M','').reset_index(drop=True)
My question is since python variable assignment operates more like a linkage than a copy I'm wondering will the 2nd and 3rd calls to compute_stats be corrupted by manipulations to tmp_daily_df, which is a time slice of tmp_df which is referenced by tmp_weekly_df and tmp_monthly_df.