I have code similar to this:
df = raw_report[some_columns].copy()
df.drop_duplicates(inplace=True)
I used copy()
to avoid a warning about uncertainty wrt view / copy. However, I'd like to use a view, because later I only read from this DataFrame
. The line that generated the warning was the line that removes duplicates, so I assume it doesn't generate a view.
Thus, my question: is there a way to remove duplicates from the view? Or, rather, is there a way to refine a view such that it doesn't contain duplicates?
我认为您只需要通过DataFrame.drop_duplicates
某些列来放置重复项的参数子集:
raw_report.drop_duplicates(subset=[some_columns],inplace=True)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.