2024-heraklion-data/exercises/pandas_intro/.ipynb_checkpoints/pandas_intro-checkpoint.ipynb
2024-08-27 15:27:53 +03:00

228 lines
4.5 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "560f48cd",
"metadata": {},
"source": [
"# Exercise: Have a look at the neural data using Pandas"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "f7777604",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"# Set some Pandas options: maximum number of rows/columns it's going to display\n",
"pd.set_option('display.max_rows', 1000)\n",
"pd.set_option('display.max_columns', 100)"
]
},
{
"cell_type": "markdown",
"id": "6494fb41",
"metadata": {},
"source": [
"# Load electrophysiology data"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "9ca3bec6",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('../../data/QC_passed_2024-07-04_collected.csv')"
]
},
{
"cell_type": "markdown",
"id": "0d78a63e",
"metadata": {},
"source": [
"## 1. How many rows/columns does the data set have?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4b68e5a6",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "0fab635e",
"metadata": {},
"source": [
"## 2. Display the first 5 rows of the DataFrame"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4adcd5bf",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "deecdfa0",
"metadata": {},
"source": [
"## 3. Display the names and dtypes of all the columns"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "64df567c",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "411f4228",
"metadata": {},
"source": [
"## 4. Display the unique values of the `high K concentration` and of the `treatment` columns"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b90ce541",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "1e395e8d",
"metadata": {},
"source": [
"## 5. Display the main statistics of the `max_spikes` column"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e2b86159",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "c8c9f6b2",
"metadata": {},
"source": [
"## 6. Show all the rows where the max number of spikes is larger than 50"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c449e9ff",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "ce9ff32b",
"metadata": {},
"source": [
"## 7. Display the main statistics of `'max_spikes'`, for the rows where `high K concentration` is `8 mM` and `15 mM` (separately)\n",
"\n",
"Are the distributions any different?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8b84faa2",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "8b2d1c2b",
"metadata": {},
"source": [
"## 8. Display the statistics of `max_spikes` when `high K concentration` is `8 mM`, and the maximum number of spikes is <= 100\n",
"\n",
"Does that change your conclusion?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1201f7d1",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "6dbbf6c8",
"metadata": {},
"source": [
"## 9. Transform the `high K concentration` column into a numerical column\n",
"\n",
"a) Discard the last three characters of the columns (`' mM'`)\n",
"\n",
"b) Use `.astype(float)` to convert to floating point numbers\n",
"\n",
"c) Save the result in a column `K (mM)`"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1cf5c15d",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "ecc0cad1",
"metadata": {},
"outputs": [],
"source": []
}
],
"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.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}