본문 바로가기
파이썬

파이썬 데이터 프레임에 사전 추가

by º기록 2020. 10. 8.
반응형

다음과 같은 사전을 반환하는 함수가 있습니다.

{'truth': 185.179993, 'day1': 197.22307753038834, 'day2': 197.26118010160317, 'day3': 197.19846975345905, 'day4': 197.1490578795196, 'day5': 197.37179265011116}

이 사전을 다음과 같이 데이터 프레임에 추가하려고합니다.

output = pd.DataFrame()
output.append(dictionary, ignore_index=True)
print(output.head())

불행히도 데이터 프레임을 인쇄하면 빈 데이터 프레임이 생성됩니다. 어떤 아이디어?

 

해결 방법

 

결과에 값을 할당하지 않습니다.

output = pd.DataFrame()
output = output.append(dictionary, ignore_index=True)
print(output.head())

 

참조 페이지 https://stackoverflow.com/questions/51774826

 

 

반응형

댓글