【发布时间】:2021-03-08 12:33:08
【问题描述】:
我有一个列向量,比如 30 个值 (1-30)第三列。我将如何使用 Pandas 或 NumPy 实现这一点?
import pandas as pd
#Create data
df = pd.DataFrame(np.linspace(1,20,20))
print(df)
1
2
:
28
29
30
为了得到这样的东西:
# Manipulate the column vector to make columns where the first column has 5
# the second column has 10 and the last column has 15 values
'T1' 'T2' 'T3'
1 6 16
2 7 17
3 8 18
4 9 19
5 10 20
NA 11 21
NA 12 22
NA 13 23
NA 14 24
NA 15 25
NA NA 26
NA NA 27
NA NA 28
NA NA 29
NA NA 30
【问题讨论】:
标签: python arrays pandas numpy