본문 바로가기

Missing2

Python 기존의 csv 파일에 판다스 데이터를 추가하는 방법은 무엇인가요?, How to add pandas data to an existing csv file? 질문 저는 pandas의 to_csv() 함수를 사용하여 기존의 csv 파일에 데이터프레임을 추가할 수 있는지 알고 싶습니다. csv 파일은 로드된 데이터와 동일한 구조를 가지고 있습니다. 답변 판다스 to_csv 함수에서는 파이썬 쓰기 모드를 지정할 수 있습니다. 추가 모드는 'a'입니다. 귀하의 경우: df.to_csv('my_csv.csv', mode='a', header=False) 기본 모드는 'w'입니다. 파일이 처음에 없을 수 있는 경우, 다음과 같은 변형을 사용하여 첫 번째 쓰기 시 헤더가 인쇄되도록 할 수 있습니다: output_path='my_csv.csv' df.to_csv(output_path, mode='a', header=not os.path.exists(output_path)) 2023. 11. 24.
Python pip install mysql-python가 환경 오류로 실패했습니다: mysql_config를 찾을 수 없습니다., pip install mysql-python fails with EnvironmentError: mysql_config not found 질문 This is the error I get (mysite)zjm1126@zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install mysql-python Downloading/unpacking mysql-python Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded Running setup.py egg_info for package mysql-python sh: mysql_config: not found Traceback (most recent call last): File "", line 14, in File "/home/zjm1126/zjm_test/mysite/build/mysql-python/setup.p.. 2023. 6. 7.