[Python] If using all scalar values, you must pass an index

2022. 9. 20. 13:14파이썬

[Python] If using all scalar values, you must pass an index

json 배열이 아닌 단순 json을 dataframe으로 변환할 경우 해당 오류를 반환한다.

(1) 데이터 설정시 인덱스값을 설정해준다

df = pd.DataFrame({'col1': 1, 

                  'col2': 2}, 

                  index = [0])

(2) 단순 json을 배열안에 넣어서 dataframe을 선언한다.

df = pd.DataFrame([{'col1': 1, 

                  'col2': 2}])

'파이썬' 카테고리의 다른 글

[python] df.drop if exists  (0) 2022.10.13
[Python] json to dataframe (+ chain key)  (0) 2022.09.20
[Python] conda 가상환경 관리  (0) 2022.09.18
[python] list slicing  (0) 2022.09.05
[Python] 현재 작업 경로 디렉토리 얻기  (0) 2022.09.01