본문 바로가기

data10

Python 데이터프레임의 열을 정규화하십시오., Normalize columns of a dataframe 질문 나는 각 열이 다른 값 범위를 가진 판다스 데이터프레임을 가지고 있습니다. 예를 들면: df: A B C 1000 10 0.5 765 5 0.35 800 7 0.09 이 데이터프레임의 열을 정규화하여 각 값이 0과 1 사이에 있도록 하는 방법이 있을까요? 원하는 출력은 다음과 같습니다: A B C 1 1 1 0.765 0.5 0.7 0.8 0.7 0.18(즉, 0.09/0.5) 답변 하나의 쉬운 방법은 Pandas를 사용하는 것입니다: (여기에서 평균 정규화를 사용하고 싶습니다) normalized_df=(df-df.mean())/df.std() min-max 정규화를 사용하려면: normalized_df=(df-df.min())/(df.max()-df.min()) 편집: 일부 우려 사항을 해결하기.. 2023. 11. 13.
Python 오류 "(유니코드 오류) 'unicodeescape' 코덱은 위치 2-3의 바이트를 디코드 할 수 없습니다: 잘린 \UXXXXXXXX 이스케이프" [중복], Error "(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: trunc.. 질문 I'm trying to read a CSV file into Python (Spyder), but I keep getting an error. My code: import csv data = open("C:\Users\miche\Documents\school\jaar2\MIK\2.6\vektis_agb_zorgverlener") data = csv.reader(data) print(data) I get the following error: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape I have tried to replace the \ w.. 2023. 10. 18.
Python 판다스 데이터프레임의 열에서 NaN 값을 0으로 대체하는 방법은 무엇인가요?, How to replace NaN values by Zeroes in a column of a Pandas Dataframe? 질문 나는 아래와 같은 Pandas Dataframe을 가지고 있습니다: itm Date Amount 67 420 2012-09-30 00:00:00 65211 68 421 2012-09-09 00:00:00 29424 69 421 2012-09-16 00:00:00 29877 70 421 2012-09-23 00:00:00 30990 71 421 2012-09-30 00:00:00 61303 72 485 2012-09-09 00:00:00 71781 73 485 2012-09-16 00:00:00 NaN 74 485 2012-09-23 00:00:00 11072 75 485 2012-09-30 00:00:00 113702 76 489 2012-09-09 00:00:00 64731 77 489 2012-.. 2023. 9. 8.
Python 판다스 DataFrame이 비어 있는지 확인하는 방법은 무엇인가요?, How to check whether a pandas DataFrame is empty? 질문 판다스 DataFrame이 비어 있는지 확인하는 방법은 무엇인가요? 제 경우에는 DataFrame이 비어 있다면 터미널에 메시지를 출력하고 싶습니다. 답변 df.empty 속성을 사용하여 비어 있는지 여부를 확인할 수 있습니다: if df.empty: print('DataFrame is empty!') 출처: Pandas 문서 2023. 8. 5.