-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.py
More file actions
19 lines (16 loc) · 757 Bytes
/
utils.py
File metadata and controls
19 lines (16 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import pandas as pd
def create_dlc_points_2d_file(dlc_dataframe_filepaths):
dfs = []
for path in dlc_dataframe_filepaths:
dlc_df = pd.read_hdf(path)
dlc_df=dlc_df.droplevel([0], axis=1).swaplevel(0,1,axis=1).T.unstack().T.reset_index().rename({'level_0':'frame'}, axis=1)
dlc_df.columns.name = ''
dfs.append(dlc_df)
#create new dataframe
dlc_df = pd.DataFrame(columns=['frame', 'camera', 'label', 'x', 'y', 'likelihood'])
for i, df in enumerate(dfs):
df["camera"] = i
df.rename(columns={"bodyparts":"label"}, inplace=True)
dlc_df = pd.concat([dlc_df, df], sort=True, ignore_index=True)
dlc_df = dlc_df[['frame', 'camera', 'label', 'x', 'y', 'likelihood']]
return dlc_df