DataFrame에 반환 값을 추가하여 CSV 파일로 출력하고 기본 그래프 작업을 수행 할 수 있지만 오류 메시지가 나타납니다. ValueError: Length of values does not match length of index
. 특히 열의 길이는 신경 쓰지 않지만 목록의 첫 번째 요소가 인덱스 0에 나타나도록 인덱스를 보장 할 수 있다면 궁금합니다. 그 다음 모든 값은 NaN
의 패딩으로 이어지는 값으로 나타납니다. 필요한 경우 끝. 이거 팬더에서 할 수 있니?DataFrame에 열을 추가 할 때 열 길이를 무시하십시오.
for idx, col in enumerate(df.T.index.values):
print "On " + str(idx) + " of " + str(len(df.T.index.values))
startDate = dt.datetime.strptime(col.split()[0], "%m/%d/%y")
endDate = startDate + dt.timedelta(days=91)
returns1 = getReturnsForPeriod(df[col][1], startDate, endDate)
retval[(col.split()[0], df[col][1], df[col][0])] = [ret for ret in returns1]
returns2 = getReturnsForPeriod(df[col][2], startDate, endDate)
retval[(col.split()[0], df[col][2], df[col][0])] = [ret for ret in returns2]
returns3 = getReturnsForPeriod(df[col][3], startDate, endDate)
retval[(col.split()[0], df[col][3], df[col][0])] = [ret for ret in returns3]
returns4 = getReturnsForPeriod(df[col][4], startDate, endDate)
retval[(col.split()[0], df[col][4], df[col][0])] = [ret for ret in returns4]
은 내가 당신이 뭘하려는 건지에 대한 설명이 더 필요하다고 생각하지만, 무엇을 찾고있어. – exp1orer