_property _DataFrame.T
返回转置。
import pandas as pd
df = pd.DataFrame({'site':['google', 'baidu', 'wiki', 'pandas'],
'age':[18, 39, 22, 45],
'price': [1.0, 2.0, 3.0, 4.0],
'color': ['red', 'black', 'blue', 'red']}, index=['first', 'second', 'third', 'forth'])
df.T
---------------------------------------转置之前
site age price color
first google 18 1.0 red
second baidu 39 2.0 black
third wiki 22 3.0 blue
forth pandas 45 4.0 red
---------------------------------------转置之后
first second third forth
site google baidu wiki pandas
age 18 39 22 45
price 1 2 3 4
color red black blue red