不知道爲什麼.dropnan()
不會刪除帶有NaN值的單元格?在熊貓蟒蛇中掉落NaN
請幫忙,我已經通過了熊貓文檔,不知道我在做什麼錯?
import pandas as pd
import quandl
import pandas as pd
df = quandl.get("GOOG/NYSE_SPY")
df2 = quandl.get("YAHOO/AAPL")
date = pd.date_range('2010-01-01', periods = 365)
df3 = pd.DataFrame(index = date)
df3 = df3.join(df['Open'], how = 'inner')
df3.rename(columns = {'Open': 'SPY'}, inplace = True)
df3 = df3.join(df2['Open'], how = 'inner')
df3.rename(columns = {'Open': 'AAPL'}, inplace = True)
df3['Spread'] = df3['SPY']/df3['AAPL']
df3 = df3/df3.ix[0]
df3.dropna(how = 'any')
df3.plot()
print(df3)
它不是就地操作。無論是'df3.dropna(how ='any',inplace = True)'或'df3 = df3.dropna(how ='any')'都可以工作。 – ayhan