Fix Python – What rules does Pandas use to generate a view vs a copy?

I’m confused about the rules Pandas uses when deciding that a selection from a dataframe is a copy of the original dataframe, or a view on the original.
If I have, for example,
df = pd.DataFrame(np.random.randn(8,8), columns=list(‘ABCDEFGH’), index=range(1,9))

I understand that a query returns a copy so that something like
foo = df.query(‘2 < ind....

Fix Python – Extracting specific selected columns to new DataFrame as a copy

I have a pandas DataFrame with 4 columns and I want to create a new DataFrame that only has three of the columns. This question is similar to: Extracting specific columns from a data frame but for pandas not R. The following code does not work, raises an error, and is certainly not the pandasnic way to do it.
import pandas as pd
old = pd.DataFr….

Fix Python – How to deal with SettingWithCopyWarning in Pandas

I just upgraded my Pandas from 0.11 to 0.13.0rc1. Now, the application is popping out many new warnings. One of them like this:
E:\FinReporter\ SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_index,col_indexer] = value instead
quote_df[‘TVol’] = quote_df[‘TV….