48 KiB
48 KiB
Exercise: Have a look at the neural data using Pandas¶
In [4]:
import pandas as pd
# Set some Pandas options: maximum number of rows/columns it's going to display
pd.set_option('display.max_rows', 1000)
pd.set_option('display.max_columns', 100)
Load electrophysiology data¶
In [31]:
df = pd.read_csv('./QC_passed_2024-07-04_collected.csv')
1. How many rows/columns does the data set have?¶
In [12]:
df.shape
Out[12]:
2. Display the first 5 rows of the DataFrame¶
In [8]:
df.head(5)
Out[8]:
3. Display the names and dtypes of all the columns¶
In [15]:
df.dtypes
Out[15]:
4. Display the unique values of the high K concentration
and of the treatment
columns¶
In [17]:
df["high K concentration"].unique()
df["treatment"].unique()
Out[17]:
5. Display the main statistics of the max_spikes
column¶
In [18]:
df["max_spikes"].describe()
Out[18]:
6. Show all the rows where the max number of spikes is larger than 50¶
In [19]:
spikes_larger_50 =(df["max_spikes"] > 50)
df[spikes_larger_50]
Out[19]:
7. Display the main statistics of 'max_spikes'
, for the rows where high K concentration
is 8 mM
and 15 mM
(separately)¶
Are the distributions any different?
In [22]:
k_c_8 = (df["high K concentration"] == '8 mM')
k_c_15 = (df["high K concentration"] == '15 mM')
df[k_c_8]["max_spikes"].describe()
df[k_c_15]["max_spikes"].describe()
Out[22]:
8. Display the statistics of max_spikes
when high K concentration
is 8 mM
, and the maximum number of spikes is <= 100¶
Does that change your conclusion?
In [23]:
KM = k_c_8 & (df["max_spikes"]<= 100)
df[KM]["max_spikes"].describe()
Out[23]:
9. Transform the high K concentration
column into a numerical column¶
a) Discard the last three characters of the columns (' mM'
)
b) Use .astype(float)
to convert to floating point numbers
c) Save the result in a column K (mM)
In [32]:
df["K (mM)"] = (df["high K concentration"].str[:-2]).astype(float)
df.head()
Out[32]:
In [ ]: