Notice
														
												
											
												
												
													Recent Posts
													
											
												
												
													Recent Comments
													
											
												
												
													Link
													
											
									| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | 
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | 
| 23 | 24 | 25 | 26 | 27 | 28 | 29 | 
| 30 | 
													Tags
													
											
												
												- paramiko
 - Numpy
 - windows forms
 - Docker
 - 컨테이너
 - 핑거스타일
 - pip
 - C#
 - YOLO
 - VS Code
 - Python
 - mysql
 - nvidia-smi
 - error
 - pandas
 - C
 - JSON
 - pytorch
 - label
 - 기타 연주
 - OpenCV
 - ubuntu
 - Linux
 - SSH
 - 채보
 - Visual Studio
 - 프로그래머스
 - Selenium
 - 오류
 - C++
 
													Archives
													
											
												
												- Today
 
- Total
 
기계는 거짓말하지 않는다
Python Pandas 기본 연산 본문
Series 연산
fruit1 = Series([5, 9, 10, 3], index=['apple', 'banana', 'cherry', 'peer'])
fruit2 = Series([3, 2, 9, 5, 10], index=['apple', 'orange', 'banana', 'cherry', 'mango'])
print(fruit1)
print('-' * 20)
print(fruit2)
print('=' * 20)
print(fruit1 + fruit2)

+, -, *, /, %, // (몫 연산) 모두 가능하며 겹치지 않는 인덱스의 value는 계산되지 않고 NaN으로 표기된다.
DataFrame 연산
fruitData1 = {'Ohio':[4, 8, 3, 5], 'Texas':[0, 1, 2, 3]}
fruitFrame1 = DataFrame(fruitData1, columns=['Ohio', 'Texas'], index=['apple', 'banana', 'cherry', 'peer'])
fruitData2 = {'Ohio':[3, 0, 2, 1, 7], 'Colorado':[5, 4, 3, 6, 0]}
fruitFrame2 = DataFrame(fruitData2, columns=['Ohio', 'Colorado'], index=['apple', 'orange', 'banana', 'cherry', 'mango'])
print(fruitFrame1)
print('-' * 20)
print(fruitFrame2)
print('=' * 20)
print(fruitFrame1 + fruitFrame2)

Series 연산과 같으며, 마찬가지로 겹치지 않는 index, columns의 value결과는 계산되지 않고 NaN으로 표기된다.
'Python' 카테고리의 다른 글
| Python Pandas 기본통계 (0) | 2021.07.10 | 
|---|---|
| Python Pandas 정렬 (0) | 2021.07.03 | 
| Python Pandas(Panel Data) (0) | 2021.07.01 | 
| Python Direct kernel connection broken 에러 (0) | 2021.06.30 | 
| Python NumPy 슬라이스, 통계 (0) | 2021.06.28 | 
			  Comments