Skip to content

Commit b93cc5c

Browse files
Update get.py
1 parent a51823f commit b93cc5c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

braininventory/get.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,20 @@ def report():
100100

101101
return report
102102

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+
return len(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+
return len(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.
119+

0 commit comments

Comments
 (0)