본문 바로가기

output4

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 문자열.replace에 정규식을 입력하는 방법은 무엇인가요?, How to input a regex in string.replace? 질문 정규식 선언에 도움이 필요합니다. 입력은 다음과 같습니다: this is a paragraph with in between and then there are cases ... where the number ranges from 1-100. and there are many other lines in the txt files with such tags 필요한 출력은 다음과 같습니다: this is a paragraph with in between and then there are cases ... where the number ranges from 1-100. and there are many other lines in the txt files with such tags 다음을 시도해 보았습니다: #.. 2023. 10. 24.
Flutter 플러터를 사용하여 위젯의 한 쪽을 원형 테두리로 만드는 방법은 무엇인가요?, How to make one side circular border of widget with flutter? 질문 I'm trying to build one side circular border with Container widget in flutter. I have searched for it but can't get any solution. Container( width: 150.0, padding: const EdgeInsets.all(20.0), decoration: BoxDecoration( // borderRadius: BorderRadius.circular(30.0), /* border: Border( left: BorderSide() ),*/ color: Colors.white ), child: Text("hello"), ), 플러터에서 Container 위젯을 사용하여 한쪽에 원형 테두리를 만들.. 2023. 8. 23.
Python 해당 함수 내에서 함수 이름을 결정합니다 (traceback을 사용하지 않고)., Determine function name from within that function (without using traceback) 질문 파이썬에서는 traceback 모듈을 사용하지 않고도 함수 내에서 함수의 이름을 알아낼 수 있는 방법이 있을까요? 예를 들어, foo라는 모듈에 bar라는 함수가 있다고 가정해봅시다. foo.bar()를 실행할 때, bar 함수가 bar의 이름을 알 수 있는 방법이 있을까요? 혹은 더 좋은 방법으로는, foo.bar의 이름을 알 수 있는 방법이 있을까요? #foo.py def bar(): print "내 이름은", __myname__ # 2023. 7. 20.