Skip to content

Commit

Permalink
add fugue and duckdb
Browse files Browse the repository at this point in the history
  • Loading branch information
khuyentran1401 committed Mar 3, 2022
1 parent a907a23 commit de4c750
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions productive_tools/Fugue_and_Duckdb/preprocessing.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "5262523c",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import glob"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "46a4838c",
"metadata": {},
"outputs": [],
"source": [
"def process_files():\n",
" filenames = glob.glob(\"crypto-binance/*/*/\" + \"*.csv\")\n",
" dfs = []\n",
" for filename in filenames:\n",
" df = pd.read_csv(filename)\n",
" df['symbol'] = filename.split('/')[-1].split('.')[0]\n",
" df['time'] = pd.to_datetime(df['Open_time'], unit='ms')\n",
" df = df.drop(['Open_time'], axis=1)\n",
" dfs.append(df)\n",
"\n",
" # Concatenate all data into one DataFrame\n",
" big_frame = pd.concat(dfs, ignore_index=True)\n",
" big_frame.to_parquet(\"raw.parquet\")\n",
" \n",
"process_files()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit de4c750

Please sign in to comment.