Dataframe in eine pickle datei gespeichert

This commit is contained in:
Meiko Remiorz 2024-01-04 11:04:09 +01:00
parent bf37bde4f1
commit 62a5316adf
3 changed files with 19 additions and 84 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
# Erlaube .ipynb-Dateien
!*.ipynb
!*.pickle

View File

@ -124,20 +124,12 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": null,
"id": "2adae4ff",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Es wurden 1034 Dateien eingelesen.\n"
]
}
],
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
@ -181,95 +173,37 @@
"\n",
"# Display the first few rows of the DataFrame\n",
"#print(df.head(n=20))\n",
"rick = np.array(rick)\n",
"#rick = np.array(rick)\n",
"\n",
"# Speichern der 'kirp' Liste in einer Pickle-Datei\n",
"with open('rick.pickle', 'wb') as f:\n",
" pickle.dump(rick, f)\n"
"#with open('rick.pickle', 'wb') as f:\n",
"# pickle.dump(rick, f)\n"
]
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": null,
"id": "dfe4f964-6068-46da-8103-194525086f01",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>genome_frequencies</th>\n",
" <th>cancer_type</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>[20.331, 0.0, 25.1806, 1.1301, 0.4836, 7.3269,...</td>\n",
" <td>kirp</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>[37.0405, 0.5002, 77.4246, 4.2188, 1.0408, 29....</td>\n",
" <td>kirp</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>[45.4456, 0.0903, 74.9545, 4.843, 1.5188, 11.8...</td>\n",
" <td>kirp</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>[15.2345, 0.3393, 62.0003, 2.4412, 0.932, 2.66...</td>\n",
" <td>kirp</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>[35.0709, 0.2333, 62.8022, 2.8872, 1.0547, 18....</td>\n",
" <td>kirp</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" genome_frequencies cancer_type\n",
"0 [20.331, 0.0, 25.1806, 1.1301, 0.4836, 7.3269,... kirp\n",
"1 [37.0405, 0.5002, 77.4246, 4.2188, 1.0408, 29.... kirp\n",
"2 [45.4456, 0.0903, 74.9545, 4.843, 1.5188, 11.8... kirp\n",
"3 [15.2345, 0.3393, 62.0003, 2.4412, 0.932, 2.66... kirp\n",
"4 [35.0709, 0.2333, 62.8022, 2.8872, 1.0547, 18.... kirp"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"data_Frame = pd.DataFrame(data, columns=[\"genome_frequencies\", \"cancer_type\"])\n",
"data_Frame.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0f5cc92a-4485-4184-845e-116ea9a9776d",
"metadata": {},
"outputs": [],
"source": [
"with open('rick.pickle', 'wb') as f:\n",
" pickle.dump(rick, f)"
]
},
{
"cell_type": "markdown",
"id": "c60cbf60-d904-4ee0-8f70-588bb109368b",

BIN
rick.pickle 100644

Binary file not shown.