49 KiB
49 KiB
Exercise: Have a look at the neural data using Pandas¶
In [1]:
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 [2]:
df = pd.read_csv('../../data/QC_passed_2024-07-04_collected.csv')
1. How many rows/columns does the data set have?¶
In [3]:
df.shape
Out[3]:
2. Display the first 5 rows of the DataFrame¶
In [4]:
df.head()
Out[4]:
3. Display the names and dtypes of all the columns¶
In [5]:
df.dtypes
Out[5]:
4. Display the unique values of the high K concentration
and of the treatment
columns¶
In [6]:
df['high K concentration'].unique()
Out[6]:
In [7]:
df['treatment'].unique()
Out[7]:
In [8]:
df['OP'].nunique()
Out[8]:
5. Display the main statistics of the max_spikes
column¶
In [9]:
df['max_spikes'].describe()
Out[9]:
6. Show all the rows where the max number of spikes is larger than 50¶
In [10]:
df.loc[df['max_spikes'] > 50]
Out[10]:
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 [11]:
df.loc[df['high K concentration'] == '8 mM', 'max_spikes'].describe()
Out[11]:
In [12]:
df.loc[df['high K concentration'] == '15 mM', 'max_spikes'].describe()
Out[12]:
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 [13]:
df.loc[(df['high K concentration'] == '8 mM') & (df['max_spikes'] <= 100), 'max_spikes'].describe()
Out[13]:
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 [14]:
df['K (mM)'] = df['high K concentration'].str[:-3].astype(float)
In [15]:
df.head()
Out[15]:
In [ ]: