You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: braininventory/get.py
+17Lines changed: 17 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -100,3 +100,20 @@ def report():
100
100
101
101
returnreport
102
102
103
+
#The following block is a function that finds the number of rows that have 'true' under the key 'exists'.
104
+
def__get_exists_true(df):
105
+
returnlen(df[df['exists']==True]) #The true listed in the dataframe is the Boolean true value.
106
+
exists_true=__get_exists_true(df) #This line assigns the returned value to a variable and print the value using the variable name.
107
+
print(exists_true)
108
+
109
+
#The following block is a function that finds the number of total rows.
110
+
def__get_exists_total(df):
111
+
returnlen(df) #len counts the number of rows in the dataframe.
112
+
exists_total=__get_exists_total(df) #The value of the total number of rows is now stored to the variable exists_total.
113
+
print (exists_total)
114
+
115
+
#Now that we have the total number of exists and the total number of rows in the dataframe we can find the fraction of the total that exist using simple division.
116
+
proportion=exists_true/exists_total
117
+
print(proportion)
118
+
print(f'The proportion of samples that exists is equal to '+str(proportion) +'.') #The proportion is a variable with a numerical value that must be casted to add to other string objects in the print function.
0 commit comments