How to delete from a multidimensional array if addon_id key is not present

I have figured out all of the issues I had with this on my own up until here. So far I got this to work to the point where I am able to save data properly. The only question I have is, how do I remove arrays where addon_id is not present? I want to… Read More How to delete from a multidimensional array if addon_id key is not present

Dataframe conditional replacement with intigers

I have a dataframe column like this: df[‘col_name’].unique() >>>array([-1, ‘Not Passed, On the boundary’, 1, ‘Passed, On the boundary’, ‘Passed, Unclear result’, ‘Passes, Unclear result, On the boudnary’, ‘Rejected, Unclear result’], dtype=object) In this column, if an element contains the word ‘Passed’ as a field or as a substring, then replace the entire field with… Read More Dataframe conditional replacement with intigers

Python Optimize multiple if-else based on truthy value

I have following code in Python where based on a boolean flag I need to check a list count, wondering if there is a better way to code this in Python? If var_true: if len(something) > 0: logger.console (“Something found”) else: raise AssertionError(“something was not found”) If not var_true: if len(something) == 0: logger.console (“Something… Read More Python Optimize multiple if-else based on truthy value

Flask render template doesn't render my html page keep getting "internal server error"

Running flask 2.1 w/ python 3.10 trying to create a small app here’s my main.py file contents and directory setup from waitress import serve app = Flask(__name__, template_folder=’/templates’) @app.route("/") def startService(): return "Simple Web app" @app.route("/home") def ohok(): return render_template(‘home.html’) if __name__ == "__main__": serve(app, host="127.0.0.1", port=8080) I have my home.html file correctly formatted placed… Read More Flask render template doesn't render my html page keep getting "internal server error"

Regex to not match more than one trailing slash in string

Looking for a regex to not match more than 1 occurrence of a trailing slash api/v1 /api/v1 /api/2v1/21/ /api/blah/v1/ /api/ether/v1// /api/23v1/// Expected match /api/v1 /api/2v1/21/ /api/blah/v1/ What I tried: ^\/([^?&#\s]*)(^[\/{2,}\s])$ >Solution : In the pattern that you tried, the second part of the pattern can not match, it asserts the start of the string ^… Read More Regex to not match more than one trailing slash in string

Django "NoReverseMatch: Reverse for 'ads.views.AdListView' not found" while doing Test

I implemented some tests to check the status code of some pages, but this one with the reverse function throws me the error: django.urls.exceptions.NoReverseMatch: Reverse for ‘ads.views.AdListView’ not found. ‘ads.views.AdListView’ is not a valid view function or pattern name. Reading the documentation and some answers on stackoverflow I’m supposed to use either the view function… Read More Django "NoReverseMatch: Reverse for 'ads.views.AdListView' not found" while doing Test