Showing posts with the label Exceptions

Featured Post

SQL Query: 3 Methods for Calculating Cumulative SUM

SQL provides various constructs for calculating cumulative sums, offering flexibility and efficiency in data analysis. In this article, we explore three distinct SQL queries that facilitate the computation of cumulative sums. Each query leverages different SQL constructs to achieve the desired outcome, catering to diverse analytical needs and preferences. Using Window Functions (e.g., PostgreSQL, SQL Server, Oracle) SELECT id, value, SUM(value) OVER (ORDER BY id) AS cumulative_sum  FROM your_table; This query uses the SUM() window function with the OVER clause to calculate the cumulative sum of the value column ordered by the id column. Using Subqueries (e.g., MySQL, SQLite): SELECT, t1.value, SUM(t2.value) AS cumulative_sum FROM your_table t1 JOIN your_table t2 ON >= GROUP BY, t1.value ORDER BY; This query uses a self-join to calculate the cumulative sum. It joins the table with itself, matching rows where the id in the first table is greater than or

How to Decode Python Exception Messages Like a Pro

While developing python programs, you might see exception messages from python. Here's an explanation to understand each part of the message. Here're tips on how to understand python exceptions. You can find two kinds of exceptions. These are StandardError and StopIteration errors. Here is a chart that shows the types of python errors. Python exceptions class Python exceptions are basically three parts. Reading an error message produced by  Python is not very difficult . The error type, the error description, and the traceback. Understand the python exception message The Error Type There are so many in-built exception types in python. Here is the command to get all the exception types: [x for x in dir(__builtins__) if 'Error' in x] The Error description The text message right after the error type gives us a description of what exactly the problem was. These descriptions are sometimes very accurate, sometimes not. Sample error Traceback (most recent call last):       Fil