{"cells":[{"metadata":{"_uuid":"93293f05-e483-4025-acc1-01a236b731c6","_cell_guid":"54ed1cf4-2bd0-4f6b-b860-0ed07211d0bd","trusted":true},"cell_type":"code","source":"import os\nimport pandas as pd\nimport numpy as np\nimport PIL.Image\nimport cv2\nimport pyarrow.parquet as pq","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ebfe7d6a-c3d9-47c7-9e04-6a9453b2574d","_cell_guid":"038f1fbd-3842-4b17-a92e-737e6d72cb06","trusted":true},"cell_type":"markdown","source":"Parquet files can be read directly into pandas"},{"metadata":{"_uuid":"5fca312e-d9f3-4abb-81b1-19ded48b77a2","_cell_guid":"e1123092-472e-451c-bdd8-ab3fa8f0dcad","trusted":true},"cell_type":"code","source":"df = pd.read_parquet('/kaggle/input/bengaliai-ocr-2019/train_image_data_0.parquet')\n\ntable2 = pq.read_table('/kaggle/input/bengaliai-ocr-2019/train_image_data_0.parquet')\ntable2.to_pandas()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"74566620-a16a-4ebf-bd4e-8bff69197a11","_cell_guid":"7e75004e-8db2-431d-bba8-63850c07f6da","trusted":true},"cell_type":"markdown","source":"There's one row per image, plus an image_id column"},{"metadata":{"_uuid":"a9519b0c-b06d-4be8-b059-191c749bf490","_cell_guid":"af31f246-cd78-4946-a833-3f26e460a324","trusted":true},"cell_type":"code","source":"df.shape","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"0ca6ae5e-6d03-42b3-80af-11e6d75462f4","_cell_guid":"2a7a28f5-04d4-4a6f-942d-67102b6a0801","trusted":true},"cell_type":"code","source":"flattened_image = df.iloc[4].drop('image_id').values.astype(np.uint8)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"b7b680ad-4a77-4fc5-8b7d-095a11c44e4e","_cell_guid":"dd6d603a-9264-481f-9046-aca8021c533d","trusted":true},"cell_type":"code","source":"unpacked_image = PIL.Image.fromarray(flattened_image.reshape(137, 236))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"c826a33d-0fa8-4388-9ab1-5aeb4e877ce5","_cell_guid":"bd4158a4-4547-407e-b6a8-401ea504aa62","trusted":true},"cell_type":"code","source":"unpacked_image","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ca59787e-7ffb-4788-9c47-d23a1cffcdee","_cell_guid":"ebfc13e0-8915-4881-b8db-07f6e2c60ff5","trusted":true},"cell_type":"markdown","source":""}],"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":4,"nbformat_minor":1}