{ "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": 3, "id": "291ebbfb", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(827, 31)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.shape" ] }, { "cell_type": "markdown", "id": "0fab635e", "metadata": {}, "source": [ "## 2. Display the first 5 rows of the DataFrame" ] }, { "cell_type": "code", "execution_count": 4, "id": "908f60ae", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
OPfilenameslicecell_chcell_IDdaytreatmenthrs_incubationrepatchhrs_after_OPRsRinresting_potentialmax_spikesRheobaseAP_heigthTHmax_depolmax_repolmembra_time_constant_taucapacitancecommentsrheo_rampAP_halfwidthRheobse_rampUnnamed: 27rheos_rampcommenthigh K concentrationRMP_from_char
0OP23042023420003.abfS1123420S1c1D1TTX0.0no10.4163896.67564339.025301-74.28588924200.080.749512-35.278320336.181641-60.79101619.40510.6017670753.3801131.151009NaNNaNNaNNaNNaN8 mM-61.828554
1OP23042023420003.abfS1323420S1c3D1TTX0.0no10.4163897.86717448.728367-69.57397526300.078.448486-32.043457350.097656-67.13867217.30393.3979181585.1028371.006321NaNNaNNaNNaNNaN8 mM-60.460298
2OP23042023420003.abfS1623420S1c6D1TTX0.0no10.4163898.82013435.971082-54.95605522300.076.660156-29.827881270.629883-52.24609414.85426.0987743173.9157971.266335NaNNaNNaNNaNNaN8 mM-59.615979
3OP23042023420003.abfS1723420S1c7D1TTX0.0yes10.4163897.26919539.186101-69.26879924300.075.030518-29.699707242.553711-71.41113317.15478.2733624598.0799360.994396NaNNaNNaNNaNNaN8 mM-61.173839
4OP23042023420003.abfS1823420S1c8D1TTX0.0yes10.4163896.00040031.599917-70.55053722350.081.011963-33.068848309.448242-61.40136716.65575.5139245786.9278981.182830NaNNaNNaNNaNNaN8 mM-60.956350
\n", "
" ], "text/plain": [ " OP filename slice cell_ch cell_ID day treatment \\\n", "0 OP230420 23420003.abf S1 1 23420S1c1 D1 TTX \n", "1 OP230420 23420003.abf S1 3 23420S1c3 D1 TTX \n", "2 OP230420 23420003.abf S1 6 23420S1c6 D1 TTX \n", "3 OP230420 23420003.abf S1 7 23420S1c7 D1 TTX \n", "4 OP230420 23420003.abf S1 8 23420S1c8 D1 TTX \n", "\n", " hrs_incubation repatch hrs_after_OP Rs Rin \\\n", "0 0.0 no 10.416389 6.675643 39.025301 \n", "1 0.0 no 10.416389 7.867174 48.728367 \n", "2 0.0 no 10.416389 8.820134 35.971082 \n", "3 0.0 yes 10.416389 7.269195 39.186101 \n", "4 0.0 yes 10.416389 6.000400 31.599917 \n", "\n", " resting_potential max_spikes Rheobase AP_heigth TH max_depol \\\n", "0 -74.285889 24 200.0 80.749512 -35.278320 336.181641 \n", "1 -69.573975 26 300.0 78.448486 -32.043457 350.097656 \n", "2 -54.956055 22 300.0 76.660156 -29.827881 270.629883 \n", "3 -69.268799 24 300.0 75.030518 -29.699707 242.553711 \n", "4 -70.550537 22 350.0 81.011963 -33.068848 309.448242 \n", "\n", " max_repol membra_time_constant_tau capacitance comments rheo_ramp \\\n", "0 -60.791016 19.40 510.601767 0 753.380113 \n", "1 -67.138672 17.30 393.397918 1 585.102837 \n", "2 -52.246094 14.85 426.098774 3 173.915797 \n", "3 -71.411133 17.15 478.273362 4 598.079936 \n", "4 -61.401367 16.65 575.513924 5 786.927898 \n", "\n", " AP_halfwidth Rheobse_ramp Unnamed: 27 rheos_ramp comment \\\n", "0 1.151009 NaN NaN NaN NaN NaN \n", "1 1.006321 NaN NaN NaN NaN NaN \n", "2 1.266335 NaN NaN NaN NaN NaN \n", "3 0.994396 NaN NaN NaN NaN NaN \n", "4 1.182830 NaN NaN NaN NaN NaN \n", "\n", " high K concentration RMP_from_char \n", "0 8 mM -61.828554 \n", "1 8 mM -60.460298 \n", "2 8 mM -59.615979 \n", "3 8 mM -61.173839 \n", "4 8 mM -60.956350 " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head()" ] }, { "cell_type": "markdown", "id": "deecdfa0", "metadata": {}, "source": [ "## 3. Display the names and dtypes of all the columns" ] }, { "cell_type": "code", "execution_count": 5, "id": "025779f0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "OP object\n", "filename object\n", "slice object\n", "cell_ch int64\n", "cell_ID object\n", "day object\n", "treatment object\n", "hrs_incubation float64\n", "repatch object\n", "hrs_after_OP float64\n", "Rs float64\n", "Rin float64\n", "resting_potential float64\n", "max_spikes int64\n", "Rheobase float64\n", "AP_heigth float64\n", "TH float64\n", "max_depol float64\n", "max_repol float64\n", "membra_time_constant_tau float64\n", "capacitance float64\n", "comments object\n", "rheo_ramp float64\n", "AP_halfwidth float64\n", "Rheobse_ramp float64\n", "Unnamed: 27 float64\n", "rheos_ramp float64\n", "comment object\n", " float64\n", "high K concentration object\n", "RMP_from_char float64\n", "dtype: object" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.dtypes" ] }, { "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": 6, "id": "a2248e7b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(['8 mM', '15 mM'], dtype=object)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df['high K concentration'].unique()" ] }, { "cell_type": "code", "execution_count": 7, "id": "4d0f3708", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(['TTX', 'high K', 'Ctrl', 'wash in high K'], dtype=object)" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df['treatment'].unique()" ] }, { "cell_type": "code", "execution_count": 8, "id": "f3154259", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "44" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df['OP'].nunique()" ] }, { "cell_type": "markdown", "id": "1e395e8d", "metadata": {}, "source": [ "## 5. Display the main statistics of the `max_spikes` column" ] }, { "cell_type": "code", "execution_count": 9, "id": "0d196291", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "count 827.000000\n", "mean 27.920193\n", "std 57.997378\n", "min 0.000000\n", "25% 19.000000\n", "50% 26.000000\n", "75% 33.000000\n", "max 1664.000000\n", "Name: max_spikes, dtype: float64" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df['max_spikes'].describe()" ] }, { "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": 10, "id": "d907492d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
OPfilenameslicecell_chcell_IDdaytreatmenthrs_incubationrepatchhrs_after_OPRsRinresting_potentialmax_spikesRheobaseAP_heigthTHmax_depolmax_repolmembra_time_constant_taucapacitancecommentsrheo_rampAP_halfwidthRheobse_rampUnnamed: 27rheos_rampcommenthigh K concentrationRMP_from_char
70OP23113023n30003.abfS1123n30S1c1D1Ctrl0.0yes11.99277815.62708158.666581-78.06091355300.088.775635-41.577148352.294922-103.51562513.80329.3506190NaN0.811086351.581719NaNNaNNaNNaN8 mM-71.584465
74OP23113023n30037.abfS1_D2223n30S1_D2c2D2wash in high K21.0no32.6994447.42644265.804793-67.54455661250.077.716064-36.505127246.459961-74.34082012.50200.2933988; exclude; Rs_end > 30NaN0.950158322.090736NaNNaNNaNNaN8 mM-59.579331
262OP23080823808003.abfS1623808S1c6D1TTX0.0no8.16333310.394754106.082649-83.3007811664-300.071.081543-15.057373237.426758-69.70214813.0598.9408615NaN1.025354NaNNaNNaNNaNNaN8 mM-32.684415
321OP23020923209012.abfS2523209S2c5D1high K0.0no-2.8747228.52573081.231493-69.04907253100.082.275391-34.912109365.478516-98.26660213.05141.8316428192.0246010.713136NaNNaNNaNNaNNaN8 mM-58.246034
396OP23081023810004.abfS1523810S1c5D1high K0.0yes5.66083325.46841279.043216-65.15502955100.085.491943-43.072510389.770508-80.07812511.45241.5927883224.5875000.966593NaNNaNNaNNaNNaN8 mM-60.860893
397OP23081023810004.abfS1723810S1c7D1high K0.0yes5.66083326.75653074.709503-64.85595753150.090.942383-42.932129423.950195-83.0078129.10239.3168545307.5403000.965371NaNNaNNaNNaNNaN8 mM-61.513494
398OP23081023810004.abfS1823810S1c8D1high K0.0no5.66083318.02366563.532613-61.41357455200.084.509277-39.605713339.843750-77.3925787.10146.6915516199.5067001.043352NaNNaNNaNNaNNaN8 mM-62.291177
558OP23031423314003.abfS1823314S1c8D1high K0.0no5.94083322.05420497.596130-67.35839852100.079.431152-41.333008325.073242-111.57226613.30186.4047905NaN0.776089NaNNaN201.505075NaNNaN8 mM-61.035575
646OP24011724118004.abfS2_D2424117S2_D2c4D1Ctrl20.0no26.42420017.188385139.095453-76.91650461100.078.436279-40.686035316.040039-95.09277319.80201.3675983NaN0.740537295.539851NaNNaNNaNNaN8 mM-59.561161
647OP24011724118004.abfS2_D2524117S2_D2c5D1Ctrl20.0no26.42420027.929918140.091217-70.42236356100.082.684326-44.421387325.561523-96.92382818.85226.1723914NaN0.769121207.006900NaNNaNNaNNaN8 mM-60.495223
\n", "
" ], "text/plain": [ " OP filename slice cell_ch cell_ID day treatment \\\n", "70 OP231130 23n30003.abf S1 1 23n30S1c1 D1 Ctrl \n", "74 OP231130 23n30037.abf S1_D2 2 23n30S1_D2c2 D2 wash in high K \n", "262 OP230808 23808003.abf S1 6 23808S1c6 D1 TTX \n", "321 OP230209 23209012.abf S2 5 23209S2c5 D1 high K \n", "396 OP230810 23810004.abf S1 5 23810S1c5 D1 high K \n", "397 OP230810 23810004.abf S1 7 23810S1c7 D1 high K \n", "398 OP230810 23810004.abf S1 8 23810S1c8 D1 high K \n", "558 OP230314 23314003.abf S1 8 23314S1c8 D1 high K \n", "646 OP240117 24118004.abf S2_D2 4 24117S2_D2c4 D1 Ctrl \n", "647 OP240117 24118004.abf S2_D2 5 24117S2_D2c5 D1 Ctrl \n", "\n", " hrs_incubation repatch hrs_after_OP Rs Rin \\\n", "70 0.0 yes 11.992778 15.627081 58.666581 \n", "74 21.0 no 32.699444 7.426442 65.804793 \n", "262 0.0 no 8.163333 10.394754 106.082649 \n", "321 0.0 no -2.874722 8.525730 81.231493 \n", "396 0.0 yes 5.660833 25.468412 79.043216 \n", "397 0.0 yes 5.660833 26.756530 74.709503 \n", "398 0.0 no 5.660833 18.023665 63.532613 \n", "558 0.0 no 5.940833 22.054204 97.596130 \n", "646 20.0 no 26.424200 17.188385 139.095453 \n", "647 20.0 no 26.424200 27.929918 140.091217 \n", "\n", " resting_potential max_spikes Rheobase AP_heigth TH \\\n", "70 -78.060913 55 300.0 88.775635 -41.577148 \n", "74 -67.544556 61 250.0 77.716064 -36.505127 \n", "262 -83.300781 1664 -300.0 71.081543 -15.057373 \n", "321 -69.049072 53 100.0 82.275391 -34.912109 \n", "396 -65.155029 55 100.0 85.491943 -43.072510 \n", "397 -64.855957 53 150.0 90.942383 -42.932129 \n", "398 -61.413574 55 200.0 84.509277 -39.605713 \n", "558 -67.358398 52 100.0 79.431152 -41.333008 \n", "646 -76.916504 61 100.0 78.436279 -40.686035 \n", "647 -70.422363 56 100.0 82.684326 -44.421387 \n", "\n", " max_depol max_repol membra_time_constant_tau capacitance \\\n", "70 352.294922 -103.515625 13.80 329.350619 \n", "74 246.459961 -74.340820 12.50 200.293398 \n", "262 237.426758 -69.702148 13.05 98.940861 \n", "321 365.478516 -98.266602 13.05 141.831642 \n", "396 389.770508 -80.078125 11.45 241.592788 \n", "397 423.950195 -83.007812 9.10 239.316854 \n", "398 339.843750 -77.392578 7.10 146.691551 \n", "558 325.073242 -111.572266 13.30 186.404790 \n", "646 316.040039 -95.092773 19.80 201.367598 \n", "647 325.561523 -96.923828 18.85 226.172391 \n", "\n", " comments rheo_ramp AP_halfwidth Rheobse_ramp \\\n", "70 0 NaN 0.811086 351.581719 \n", "74 8; exclude; Rs_end > 30 NaN 0.950158 322.090736 \n", "262 5 NaN 1.025354 NaN \n", "321 8 192.024601 0.713136 NaN \n", "396 3 224.587500 0.966593 NaN \n", "397 5 307.540300 0.965371 NaN \n", "398 6 199.506700 1.043352 NaN \n", "558 5 NaN 0.776089 NaN \n", "646 3 NaN 0.740537 295.539851 \n", "647 4 NaN 0.769121 207.006900 \n", "\n", " Unnamed: 27 rheos_ramp comment high K concentration RMP_from_char \n", "70 NaN NaN NaN NaN 8 mM -71.584465 \n", "74 NaN NaN NaN NaN 8 mM -59.579331 \n", "262 NaN NaN NaN NaN 8 mM -32.684415 \n", "321 NaN NaN NaN NaN 8 mM -58.246034 \n", "396 NaN NaN NaN NaN 8 mM -60.860893 \n", "397 NaN NaN NaN NaN 8 mM -61.513494 \n", "398 NaN NaN NaN NaN 8 mM -62.291177 \n", "558 NaN 201.505075 NaN NaN 8 mM -61.035575 \n", "646 NaN NaN NaN NaN 8 mM -59.561161 \n", "647 NaN NaN NaN NaN 8 mM -60.495223 " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[df['max_spikes'] > 50]" ] }, { "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": 11, "id": "5924179e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "count 474.000000\n", "mean 30.955696\n", "std 75.960740\n", "min 1.000000\n", "25% 21.000000\n", "50% 27.000000\n", "75% 34.000000\n", "max 1664.000000\n", "Name: max_spikes, dtype: float64" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[df['high K concentration'] == '8 mM', 'max_spikes'].describe()" ] }, { "cell_type": "code", "execution_count": 12, "id": "660e2af2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "count 353.000000\n", "mean 23.844193\n", "std 10.519791\n", "min 0.000000\n", "25% 18.000000\n", "50% 24.000000\n", "75% 31.000000\n", "max 48.000000\n", "Name: max_spikes, dtype: float64" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[df['high K concentration'] == '15 mM', 'max_spikes'].describe()" ] }, { "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": 13, "id": "eec287c7", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "count 473.000000\n", "mean 27.503171\n", "std 10.965493\n", "min 1.000000\n", "25% 21.000000\n", "50% 27.000000\n", "75% 34.000000\n", "max 61.000000\n", "Name: max_spikes, dtype: float64" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[(df['high K concentration'] == '8 mM') & (df['max_spikes'] <= 100), 'max_spikes'].describe()" ] }, { "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": 14, "id": "3a2bcc9c", "metadata": {}, "outputs": [], "source": [ "df['K (mM)'] = df['high K concentration'].str[:-3].astype(float)" ] }, { "cell_type": "code", "execution_count": 15, "id": "35061149", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
OPfilenameslicecell_chcell_IDdaytreatmenthrs_incubationrepatchhrs_after_OPRsRinresting_potentialmax_spikesRheobaseAP_heigthTHmax_depolmax_repolmembra_time_constant_taucapacitancecommentsrheo_rampAP_halfwidthRheobse_rampUnnamed: 27rheos_rampcommenthigh K concentrationRMP_from_charK (mM)
0OP23042023420003.abfS1123420S1c1D1TTX0.0no10.4163896.67564339.025301-74.28588924200.080.749512-35.278320336.181641-60.79101619.40510.6017670753.3801131.151009NaNNaNNaNNaNNaN8 mM-61.8285548.0
1OP23042023420003.abfS1323420S1c3D1TTX0.0no10.4163897.86717448.728367-69.57397526300.078.448486-32.043457350.097656-67.13867217.30393.3979181585.1028371.006321NaNNaNNaNNaNNaN8 mM-60.4602988.0
2OP23042023420003.abfS1623420S1c6D1TTX0.0no10.4163898.82013435.971082-54.95605522300.076.660156-29.827881270.629883-52.24609414.85426.0987743173.9157971.266335NaNNaNNaNNaNNaN8 mM-59.6159798.0
3OP23042023420003.abfS1723420S1c7D1TTX0.0yes10.4163897.26919539.186101-69.26879924300.075.030518-29.699707242.553711-71.41113317.15478.2733624598.0799360.994396NaNNaNNaNNaNNaN8 mM-61.1738398.0
4OP23042023420003.abfS1823420S1c8D1TTX0.0yes10.4163896.00040031.599917-70.55053722350.081.011963-33.068848309.448242-61.40136716.65575.5139245786.9278981.182830NaNNaNNaNNaNNaN8 mM-60.9563508.0
\n", "
" ], "text/plain": [ " OP filename slice cell_ch cell_ID day treatment \\\n", "0 OP230420 23420003.abf S1 1 23420S1c1 D1 TTX \n", "1 OP230420 23420003.abf S1 3 23420S1c3 D1 TTX \n", "2 OP230420 23420003.abf S1 6 23420S1c6 D1 TTX \n", "3 OP230420 23420003.abf S1 7 23420S1c7 D1 TTX \n", "4 OP230420 23420003.abf S1 8 23420S1c8 D1 TTX \n", "\n", " hrs_incubation repatch hrs_after_OP Rs Rin \\\n", "0 0.0 no 10.416389 6.675643 39.025301 \n", "1 0.0 no 10.416389 7.867174 48.728367 \n", "2 0.0 no 10.416389 8.820134 35.971082 \n", "3 0.0 yes 10.416389 7.269195 39.186101 \n", "4 0.0 yes 10.416389 6.000400 31.599917 \n", "\n", " resting_potential max_spikes Rheobase AP_heigth TH max_depol \\\n", "0 -74.285889 24 200.0 80.749512 -35.278320 336.181641 \n", "1 -69.573975 26 300.0 78.448486 -32.043457 350.097656 \n", "2 -54.956055 22 300.0 76.660156 -29.827881 270.629883 \n", "3 -69.268799 24 300.0 75.030518 -29.699707 242.553711 \n", "4 -70.550537 22 350.0 81.011963 -33.068848 309.448242 \n", "\n", " max_repol membra_time_constant_tau capacitance comments rheo_ramp \\\n", "0 -60.791016 19.40 510.601767 0 753.380113 \n", "1 -67.138672 17.30 393.397918 1 585.102837 \n", "2 -52.246094 14.85 426.098774 3 173.915797 \n", "3 -71.411133 17.15 478.273362 4 598.079936 \n", "4 -61.401367 16.65 575.513924 5 786.927898 \n", "\n", " AP_halfwidth Rheobse_ramp Unnamed: 27 rheos_ramp comment \\\n", "0 1.151009 NaN NaN NaN NaN NaN \n", "1 1.006321 NaN NaN NaN NaN NaN \n", "2 1.266335 NaN NaN NaN NaN NaN \n", "3 0.994396 NaN NaN NaN NaN NaN \n", "4 1.182830 NaN NaN NaN NaN NaN \n", "\n", " high K concentration RMP_from_char K (mM) \n", "0 8 mM -61.828554 8.0 \n", "1 8 mM -60.460298 8.0 \n", "2 8 mM -59.615979 8.0 \n", "3 8 mM -61.173839 8.0 \n", "4 8 mM -60.956350 8.0 " ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head()" ] }, { "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 }