티스토리 뷰

공부

[pandas] dataframe (with T)

승가비 2022. 9. 11. 20:29
728x90
import pandas as pd

df = pd.DataFrame({'X': [0, 1, 2], 'Y': [3, 4, 5]}, index=['A', 'B', 'C'])
print(df)
#    X  Y
# A  0  3
# B  1  4
# C  2  5

print(df.T)
#    A  B  C
# X  0  1  2
# Y  3  4  5

https://note.nkmk.me/en/python-pandas-t-transpose/

 

pandas: Transpose DataFrame (swap rows and columns) | note.nkmk.me

Use the T attribute or the transpose() method to swap (= transpose) the rows and columns of pandas.DataFrame.Neither method changes the original object but returns a new object with the rows and columns swapped (= transposed object).Note that depending on

note.nkmk.me

 

728x90

'공부' 카테고리의 다른 글

[spark] sql yesterday  (0) 2022.09.14
[MySQL] PK 복합키 순서에 따라 인덱스가 타지 않을 수 있다!  (0) 2022.09.11
[MySQL] Partition  (0) 2022.09.11
[jenkins] aws cli  (0) 2022.09.11
Limitation of Distributed System  (0) 2022.09.11
댓글