>>> df = pd.DataFrame([[0, 2, 3], [0, 4, 1], [10, 20, 30]],
... index=[4, 5, 6], columns=['A', 'B', 'C'])
>>> df
A B C
4 0 2 3
5 0 4 1
6 10 20 30
在指定的行/列对中获取值
>>> df.at[4, 'B']
2
在指定的行/列对上设置值
>>> df.at[4, 'B'] = 10
>>> df.at[4, 'B']
10
P = []
df = pd.DataFrame(index=range(int(frames_count)))
if len(outputs) > 0:
for i in range(len(outputs)):
bbox_xyxy = outputs[:,:4]
identities = outputs[:,-1]
sx = outputs[:,0]
sy = outputs[:,1]
ex = outputs[:,2]
ey = outputs[:,3]
cx = ((sx + ex) /2)
cy = ((sy + ey) /2)
cx2 = (cx.tolist())
cy2 = (cy.tolist())
P = identities[i]
df[str(P.astype(int))] = "" #creates new column with an id number obtained through deepsort
df.at[int(framenumber), str(P.astype(int))] = [cx2[i], cy2[i]] #inputs my current coordinates into the dataframe
print(df)
1
Frames
3 [614.5, 632.0]
1
Frames
3
4 [610.5, 624.0]
1
Frames
3
4
5 [603.0, 618.0]
1
Frames
3
4
5
6 [574.0, 615.5]
1
Frames
3
4
5
6
7 [564.0, 610.0]
1
Frames
3
4
5
6
7
8 [559.0, 597.0]
1
Frames
3 [614.5, 632.0]
4 [610.5, 624.0]
5 [603.0, 618.0]
6 [574.0, 615.5]
7 [564.0, 610.0]
8 [559.0, 597.0]