파이썬 unique 함수 에러 해결해주세요.
-
게시물 수정 , 삭제는 로그인 필요
제가 이런 식으로 코드를 만들었는데요.
A = ['seoul', 'gyeonggi', 'gangwon', 'busan', 'ulsan', 'gyeongsangbuk', 'gyeongsangnam', 'gwangju', 'jeollabuk', 'jeollanam', 'jeju', 'daegu', 'daejeon', 'chungcheongbuk', 'chungcheongnam', 'incheon', 'sejong']
pd.set_option('display.max_rows', None)
for i in A :
df_2021 = pd.DataFrame(np.column_stack([globals()['_2021_{}1'.format(i)]['측정소명'].unique(), globals()['_2021_{}1'.format(i)]['측정소코드'].unique()]))
print(df_2021)
다음과 같은 에러가 떴습니다.
ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 35 and the array at index 1 has size 37
그래서 데이터를 확인해보니 제가 월별 데이터를 병합하고 위의 코드를 실행한 건데 월별로 측정소코드는 같은데 측정소명이 다른 몇 가지 때문에 에러가 뜨더라고요. 근데 어떻게 해결해야 할지 모르겠어요. 제가 원하는 것은 데이터에서 측정소명과 측정소코드를 한 쌍으로 출력하고 싶은 건데 측정소코드는 같은데 측정소명이 다른 데이터들도 같이 출력되게 하는 방법이 없을까요?
ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 35 and the array at index 1 has size 37
그래서 데이터를 확인해보니 제가 월별 데이터를 병합하고 위의 코드를 실행한 건데 월별로 측정소코드는 같은데 측정소명이 다른 몇 가지 때문에 에러가 뜨더라고요. 근데 어떻게 해결해야 할지 모르겠어요. 제가 원하는 것은 데이터에서 측정소명과 측정소코드를 한 쌍으로 출력하고 싶은 건데 측정소코드는 같은데 측정소명이 다른 데이터들도 같이 출력되게 하는 방법이 없을까요?
#파이썬 unique #파이썬 unique count #파이썬 unique 정렬 #파이썬 unique list #파이썬 groupby unique count #파이썬 np.unique