---
# System prepended metadata

title: Python Pandas DataFrame で行と列を入れ替える 2021-07-26
tags: [行列変換, Python, DataFrame, Pandas]

---

---
lang: ja-jp
breaks: true
---
# Python Pandas DataFrame で行と列を入れ替える 2021-07-26

```python=
display(countBSSID)
```

```shell=
## BSSID毎の出現回数を算出する...
BSSID	COUNT
0	00:05:B5:4D:04:A8	13
1	00:05:B5:96:AB:D4	18
2	00:05:B5:E6:11:F9	39
3	00:1A:EB:C9:BF:00	11461
4	00:1A:EB:C9:BF:01	21935
...	...	...
217	FA:8F:CA:95:0E:DF	11
218	FA:B7:97:00:90:7B	25
219	FC:62:B9:75:3E:68	53
220	FC:87:43:01:55:31	78
221	FE:46:D7:20:10:9B	13
```

```python=
# 行と列を入れ替える（転置）
display(countBSSID.T)
```

```shell=
0	1	2	3	4	5	6	7	8	9	...	212	213	214	215	216	217	218	219	220	221
BSSID	00:05:B5:4D:04:A8	00:05:B5:96:AB:D4	00:05:B5:E6:11:F9	00:1A:EB:C9:BF:00	00:1A:EB:C9:BF:01	00:1A:EB:C9:BF:10	00:1A:EB:C9:C1:40	00:1A:EB:C9:C1:41	00:1A:EB:C9:C1:50	00:1A:EB:C9:C1:80	...	F8:B7:97:0D:34:B3	F8:B7:97:A8:57:67	F8:B7:97:F0:11:C7	FA:49:FA:6E:B6:34	FA:62:BC:EF:85:A4	FA:8F:CA:95:0E:DF	FA:B7:97:00:90:7B	FC:62:B9:75:3E:68	FC:87:43:01:55:31	FE:46:D7:20:10:9B
COUNT	13	18	39	11461	21935	180	425	2648	580	13419	...	14	11	14	18	16	11	25	53	78	13
2 rows × 222 columns
```

###### tags: `Pandas` `Python` `DataFrame` `行列変換`
