1
현재 다음 코드로 숫자를 롤백 중입니다. dataframe
의 각 요소에 대해 합계 기준을 설정하는 몇 가지 조건이 있지만 작성된 보고서 중 가장 느린 부분입니다. 특정 문자열로 시작하는 데이터 프레임의 모든 요소를 식별하는 더 빠른 방법이 있습니까?문자열을 시작으로하는 데이터 프레임 열의 모든 요소를 찾습니다.
for idx, eachRecord in attributionCalcDF.T.iteritems():
if (attributionCalcDF['SEC_ID'].ix[idx] == 0):
currentGroup = lambda x: str(x).startswith(attributionCalcDF['GROUP_LIST'].ix[idx])
currentGroupArray = attributionCalcDF['GROUP_LIST'].map(currentGroup)
attributionCalcDF['ROLLUP_DAILY_TIMING_IMPACT'].ix[idx] = (
attributionCalcDF['DAILY_TIMING_IMPACT'][(attributionCalcDF['SEC_ID'] != 0) &
(currentGroupArray) &
(attributionCalcDF['START_DATE'] == attributionCalcDF['START_DATE'].ix[idx])].sum())
attributionCalcDF['ROLLUP_DAILY_STOCK_TO_GROUP_IMPACT'].ix[idx] = (
attributionCalcDF['DAILY_STOCK_TO_GROUP_IMPACT'][(attributionCalcDF['SEC_ID'] != 0) &
(currentGroupArray) &
(attributionCalcDF['START_DATE'] == attributionCalcDF['START_DATE'].ix[idx])].sum())
감사합니다. Wes. 이 기능의 시간이 ~ 40 % 향상되었습니다. 벡터화 된 문자열 함수? ... 대단히 기대! –