Pandas Copy Warning - Quant Trader Interview Question
Difficulty: Medium
Category: Code Analysis
Practice quant interview questions from top firms including Jane Street, Citadel, Two Sigma, DE Shaw, and other leading quantitative finance companies.
Topics: pandas, data-manipulation, copy-vs-view, settingwithcopywarning
Problem Description
You are analyzing historical stock data using Pandas. You have a DataFrame df containing 'price' and other columns. You attempt to add a 'flag' column to rows where the 'price' is greater than 100, setting the 'flag' to True. However, after executing the following code, you observe that the original DataFrame df remains unchanged.
Why does the assignment dfdf'price' > 100'flag' = True not modify the original DataFrame df?
Practice this medium trader interview question on MyntBit - the all-in-one quant learning platform with 200+ quant interview questions for Jane Street, Citadel, Two Sigma, and other top quantitative finance firms.