最佳答案
我刚刚将我的熊猫从0.11升级到0.13.0rc1。现在,应用程序弹出了许多新的警告。其中一个像这样:
E:\FinReporter\FM_EXT.py:449: 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 insteadquote_df['TVol'] = quote_df['TVol']/TVOL_SCALE
我想知道这到底是什么意思?我需要改变什么吗?
如果我坚持使用quote_df['TVol'] = quote_df['TVol']/TVOL_SCALE
,我应该如何暂停警告?
def _decode_stock_quote(list_of_150_stk_str):"""decode the webpage and return dataframe"""
from cStringIO import StringIO
str_of_all = "".join(list_of_150_stk_str)
quote_df = pd.read_csv(StringIO(str_of_all), sep=',', names=list('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefg')) #dtype={'A': object, 'B': object, 'C': np.float64}quote_df.rename(columns={'A':'STK', 'B':'TOpen', 'C':'TPCLOSE', 'D':'TPrice', 'E':'THigh', 'F':'TLow', 'I':'TVol', 'J':'TAmt', 'e':'TDate', 'f':'TTime'}, inplace=True)quote_df = quote_df.ix[:,[0,3,2,1,4,5,8,9,30,31]]quote_df['TClose'] = quote_df['TPrice']quote_df['RT'] = 100 * (quote_df['TPrice']/quote_df['TPCLOSE'] - 1)quote_df['TVol'] = quote_df['TVol']/TVOL_SCALEquote_df['TAmt'] = quote_df['TAmt']/TAMT_SCALEquote_df['STK_ID'] = quote_df['STK'].str.slice(13,19)quote_df['STK_Name'] = quote_df['STK'].str.slice(21,30)#.decode('gb2312')quote_df['TDate'] = quote_df.TDate.map(lambda x: x[0:4]+x[5:7]+x[8:10])
return quote_df
E:\FinReporter\FM_EXT.py:449: 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 insteadquote_df['TVol'] = quote_df['TVol']/TVOL_SCALEE:\FinReporter\FM_EXT.py:450: 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 insteadquote_df['TAmt'] = quote_df['TAmt']/TAMT_SCALEE:\FinReporter\FM_EXT.py:453: 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 insteadquote_df['TDate'] = quote_df.TDate.map(lambda x: x[0:4]+x[5:7]+x[8:10])