我是熊貓的初學者。我想從excel文件中提取一列到pandas的python數組中。我想要在整個列中運行一個循環。我想在column.Here打印第1個數據是我的代碼:IndexError:索引超出熊貓的範圍
import pandas as pd
xl_workbook = pd.ExcelFile("Summary.xlsx") # Load the excel workbook
df = xl_workbook.parse("Sheet1") # Parse the sheet into a dataframe
df['transactionqtr'] = pd.to_datetime(df['transactionqtr'],errors ='coerce')
df['commencementdate'] = pd.to_datetime(df['commencementdate'],errors ='coerce')
df=df.dropna()
df['transactionqtr'] = df['transactionqtr'].apply(lambdax:x.date().strftime('%m%d%y'))
df['commencementdate'] = df['commencementdate'].apply(lambda x:x.date().strftime('%m%d%y'))
arr1 = df['transactionqtr'][1][1]
arr2 = df['commencementdate'][1][1]
print(arr1)
print(arr2)
但它顯示IndexError:索引越界在這條線:
arr1 = df['transactionqtr'][1][1]
arr2 = df['commencementdate'][1][1]
我應該怎樣解決這個問題?請也指導我更好的代碼。
您可以包括整個錯誤消息? – acdr