JavaScript
x
15
15
1
def my_function(df_1) :
2
3
df_1 = df_1.filter[['col_1','col_2','col_3']]
4
5
# Keeping only those records where col_1 == 'success'
6
df_1 = df_1[df_1['col_1'] == 'success']
7
8
# Checking if the df_1 shape is 0
9
if df_1.shape[0]==0:
10
print('No records found')
11
break
12
13
#further program
14
15
I am looking to break the execution of further program if the if condition is met.
is this the correct way to do so..? since break only ends the loop, but i want to end the function
Advertisement
Answer
You need to use
JavaScript
1
4
1
if df_1.shape[0]==0:
2
print('No records found')
3
return
4