## Posts

Showing posts with the label python-dictionary

### 5 SQL Queries That Popularly Used in Data Analysis

Here are five popular SQL queries frequently used in data analysis. 1. SELECT with Aggregations Summarize data by calculating aggregates like counts, sums, averages, etc. SELECT department, COUNT(*) as employee_count, AVG(salary) as average_salary FROM employees GROUP BY department; 2. JOIN Operations  Combine data from multiple tables based on a related column. SELECT e.employee_id, e.name, d.department_name FROM employees e JOIN departments d ON e.department_id = d.department_id; 3. WHERE Clause for Filtering Filter records based on specified conditions. SELECT * FROM sales WHERE sale_date BETWEEN '2024-01-01' AND '2024-12-31'   AND amount > 1000; 4. ORDER BY Clause for Sorting Sort results in ascending or descending order based on one or more columns. SELECT product_name, price FROM products ORDER BY price DESC; 5. GROUP BY with HAVING Clause Group records and apply conditions to the aggregated results. SELECT department, SUM(salary) as total_salaries FROM employ

# Python Subset: How to Get Subset of Dictionary

Here's a sample program to get the python subset. In this case, you'll find logic for dictionary subsets. Dictionary python To illustrate, I have taken a dictionary as below with keys and values. my_first_dict = { 'HP': 100 'IBM': 200 'NTT': 300 'ABC': 400 'GDF': 500 } I want to make a subset of values greater than 100 and less than 400. How can you achieve this? No worries, below, you will find the logic. Logic to get subset out of a dictionary I am using dictionary comprehension to achieve this. Syntax: sub_set = { key:value for key, value in my_first_dict.items() value >100 and value <400} Result References Python Programming: Using Problem-Solving Approach