forked from joaoestevanbarbosa/Data-science
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a907a23
commit de4c750
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |