{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np \nimport pandas as pd ","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-03-14T15:33:11.116154Z","iopub.execute_input":"2023-03-14T15:33:11.116604Z","iopub.status.idle":"2023-03-14T15:33:11.122189Z","shell.execute_reply.started":"2023-03-14T15:33:11.116566Z","shell.execute_reply":"2023-03-14T15:33:11.120931Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df=pd.read_parquet('/kaggle/input/asl-signs/train_landmark_files/16069/100015657.parquet')\ndf","metadata":{"execution":{"iopub.status.busy":"2023-03-14T15:33:11.124717Z","iopub.execute_input":"2023-03-14T15:33:11.125711Z","iopub.status.idle":"2023-03-14T15:33:11.168747Z","shell.execute_reply.started":"2023-03-14T15:33:11.125658Z","shell.execute_reply":"2023-03-14T15:33:11.167302Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.groupby('frame').count()","metadata":{"execution":{"iopub.status.busy":"2023-03-14T15:33:11.171189Z","iopub.execute_input":"2023-03-14T15:33:11.171688Z","iopub.status.idle":"2023-03-14T15:33:11.195821Z","shell.execute_reply.started":"2023-03-14T15:33:11.171660Z","shell.execute_reply":"2023-03-14T15:33:11.194297Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Our task we only need hand landmarks\n# for a given frame\ndf[df['frame'] == 103]","metadata":{"execution":{"iopub.status.busy":"2023-03-14T15:33:11.197497Z","iopub.execute_input":"2023-03-14T15:33:11.197856Z","iopub.status.idle":"2023-03-14T15:33:11.214941Z","shell.execute_reply.started":"2023-03-14T15:33:11.197825Z","shell.execute_reply":"2023-03-14T15:33:11.213940Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Now we need to check for 'hands'  \ndf[(df['frame'] == 103) & (df['type'].str.contains('hand')) ]","metadata":{"execution":{"iopub.status.busy":"2023-03-14T15:33:11.217356Z","iopub.execute_input":"2023-03-14T15:33:11.217663Z","iopub.status.idle":"2023-03-14T15:33:11.260474Z","shell.execute_reply.started":"2023-03-14T15:33:11.217636Z","shell.execute_reply":"2023-03-14T15:33:11.259354Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#From above we need to get x and y per each frame related to hands , ( separate for L and R )\n# use like \nfor I, gdf in df.groupby('frame'):  # I is index in this case Frame number\n    #do your processing to gdf \n    gdf=gdf[gdf['type'].str.contains('hand')]\n    gdf=gdf.loc[:,[\"frame\",\"x\",\"y\"]].fillna(0)\n    gdf['x']=gdf['x']*256\n    gdf['y']=gdf['y']*256\n    gdf=gdf.astype(int)\n    \n    arry1=np.array(gdf.drop([\"frame\"],axis=1).to_numpy()).tolist()\n    #arry1=arry1.astype('int')\n    #print(arry1[0])\n    print(arry1)\n    \n        \n","metadata":{"execution":{"iopub.status.busy":"2023-03-14T15:52:56.408557Z","iopub.execute_input":"2023-03-14T15:52:56.408886Z","iopub.status.idle":"2023-03-14T15:52:56.728852Z","shell.execute_reply.started":"2023-03-14T15:52:56.408859Z","shell.execute_reply":"2023-03-14T15:52:56.726576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#df=df[(df['type'].str.contains('hand')) ].fillna(0)\n#df['x']=df['x']*256\n#df['y']=df['y']*256\n#df=df.loc[:,[\"frame\",\"x\",\"y\"]]\n#keep = [x for x in df.columns if x != 'frame']\n#arry=np.array(df.groupby('frame')[keep].apply(lambda x: x.values.tolist()).tolist())\n#arry.astype('int')","metadata":{"execution":{"iopub.status.busy":"2023-03-14T15:33:11.519348Z","iopub.execute_input":"2023-03-14T15:33:11.519659Z","iopub.status.idle":"2023-03-14T15:33:11.525102Z","shell.execute_reply.started":"2023-03-14T15:33:11.519630Z","shell.execute_reply":"2023-03-14T15:33:11.523922Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"frames=pd.unique(df['frame'].to_numpy())\nframes","metadata":{"execution":{"iopub.status.busy":"2023-03-14T16:13:42.433519Z","iopub.execute_input":"2023-03-14T16:13:42.433984Z","iopub.status.idle":"2023-03-14T16:13:42.447819Z","shell.execute_reply.started":"2023-03-14T16:13:42.433949Z","shell.execute_reply":"2023-03-14T16:13:42.444406Z"},"trusted":true},"execution_count":null,"outputs":[]}]}