본문 바로가기

분류 전체보기980

Python 판다스 데이터프레임의 열 또는 행에서 목록을 가져오는 방법은 무엇인가요?, Get list from pandas dataframe column or row? 질문 나는 다음과 같이 엑셀 문서에서 가져온 데이터프레임 df를 가지고 있습니다: cluster load_date budget actual fixed_price A 1/1/2014 1000 4000 Y A 2/1/2014 12000 10000 Y A 3/1/2014 36000 2000 Y B 4/1/2014 15000 10000 N B 4/1/2014 12000 11500 N B 4/1/2014 90000 11000 N C 7/1/2014 22000 18000 N C 8/1/2014 30000 28960 N C 9/1/2014 53000 51200 N 나는 for루프를 실행하고 각 클러스터마다 엑셀 워크시트를 생성하기 위해 열 1의 내용인 df['cluster']을 리스트로 반환하고 싶습니다. 또한, 전.. 2023. 10. 5.
Python 축 눈금 라벨 회전, Rotate axis tick labels 질문 I can't figure out how to rotate the text on the X Axis. Its a time stamp, so as the number of samples increase, they get closer and closer until they overlap. I'd like to rotate the text 90 degrees so as the samples get closer together, they aren't overlapping. Below is what I have, it works fine with the exception that I can't figure out how to rotate the X axis text. import sys import matp.. 2023. 10. 5.
Python 명령 줄에서 함수 실행하기, Run function from the command line 질문 나는 이 코드를 가지고 있습니다: def hello(): return 'Hi :)' 이 코드를 어떻게 명령 줄에서 직접 실행할 수 있을까요? 답변 다음은 -c (명령어) 인수를 사용하는 경우입니다 (파일 이름이 foo.py라고 가정합니다): $ python -c 'import foo; print foo.hello()' 또는 네임스페이스 오염에 대해 신경 쓰지 않는 경우: $ python -c 'from foo import *; print hello()' 중간 지점은 다음과 같습니다: $ python -c 'from foo import hello; print hello()' 2023. 10. 5.
Python 파이썬에서 집합에 값을 추가하십시오., Append values to a set in Python 질문 기존 set에 값 추가하는 방법은 무엇인가요? 답변 your_set.update(your_sequence_of_values) 예를 들어, your_set.update([1, 2, 3, 4])와 같이 사용할 수 있습니다. 또는, 다른 이유로 인해 루프에서 값을 생성해야 하는 경우에는 for value in ...: your_set.add(value) 하지만, 물론, 가능한 경우에는 한 번의 .update 호출로 일괄적으로 처리하는 것이 더 빠르고 편리합니다. 2023. 10. 5.