0
當我嘗試複製使用instructions provided in the online documentation的熊貓面板對象時,我沒有得到預期的行爲。熊貓面板的深層副本?
這也許可以說明問題:
import pandas as pd
# make first panel with some bogus numbers
dates = pd.date_range('20130101',periods=6)
df1 = pd.DataFrame(np.random.randn(6,4),index=dates,columns=list('ABCD'))
df2 = pd.DataFrame(np.random.randn(6,4),index=dates,columns=list('EFGH'))
pnl = {}
pnl['alpha'] = df1
pnl['beta'] = df2
# copy pnl into pnl2
# according to online docs the default is 'deep=True'
# but it chokes when I try to specify deep=True
pnl2 = pnl.copy()
# now delete column C from pnl2['alpha']
del pnl2['alpha']['C']
#Now when I try to find column C in the original panel (pnl) it's gone!
我想必須有一個漂亮的解決方案,這一點,但在在線文檔我找不到它,也不是韋斯·麥金尼的書(我唯一的書熊貓...)。
任何提示/建議非常感謝!
DOH!謝謝。寫作課程正在成爲培養謙卑的有力援助。 – 2014-10-02 18:14:59