Posts

Featured Post

SQL Interview Success: Unlocking the Top 5 Frequently Asked Queries

Image
 Here are the five top commonly asked SQL queries in the interviews. These you can expect in Data Analyst, or, Data Engineer interviews. Top SQL Queries for Interviews 01. Joins The commonly asked question pertains to providing two tables, determining the number of rows that will return on various join types, and the resultant. Table1 -------- id ---- 1 1 2 3 Table2 -------- id ---- 1 3 1 NULL Output ------- Inner join --------------- 5 rows will return The result will be: =============== 1  1 1   1 1   1 1    1 3    3 02. Substring and Concat Here, we need to write an SQL query to make the upper case of the first letter and the small case of the remaining letter. Table1 ------ ename ===== raJu venKat kRIshna Solution: ========== SELECT CONCAT(UPPER(SUBSTRING(name, 1, 1)), LOWER(SUBSTRING(name, 2))) AS capitalized_name FROM Table1; 03. Case statement SQL Query ========= SELECT Code1, Code2,      CASE         WHEN Code1 = 'A' AND Code2 = 'AA' THEN "A" | "A

Python - How to Lookup Dictionary by Key

Image
Here's Python Dictionary that explained how to lookup it using Key. Dictionary in Python is Key/Value pair. It's different from the list. The basic rule to identify; is enclosed in flower brackets ({}). Here's a demo about lookup and how to test it.  Dictionary = { 'key' : 'value', 'key: value'  }   IN THIS PAGE Python Dictionary Python Lookup How to check Lookup working or not Dictionary Example my_dict = {'name' : 'srini' , 'salary' : '100000', 'skills' : 'python' } Here, 'name' is the label. Then, : Then, 'srini' -> Value Explanation Data is enclosed in flower brackets It's an unordered list You can manipulate data (mutable) You can access the value of a particular key. So, in Python, it's called a Lookup. It's one of the best interview questions. You May Also Like :  Python Dictionary Vs List With Examples Lookup Dictionary by Key Python Lookup (a.k.a Dictionary). You

How to Use List Function in Python

Image
Here's is an answer to calculate the length of the repeated lists. LIST is a principle data type in Python that holds a list of values. Usually strings. List() Function the Real Usage You can do various operations with Lists. The best examples are REPEAT, APPEND, INSERT, EXTEND, COUNT. Still more you can do. Note: This question is from a test recently held by an HR company. HR firms usually ask to take an online test to filter the job-seekers. IN THIS PAGE 1. Question 2. How to Find Length Interview Question  The '* 2' says times the list is repeated. In this question, they have given '2' times. my_list = ['srini', 'seetha', 'rao'] b = len(list(list(list(list(list(my_list*2)))))) Print (b) Select Answer 1. 5 2. 6 3. 7 4. None Explanation: In the first step, the '*' says, you repeated the List two times. It confuses the test-taker since they have given multiple functions of the list(). How to get Length You can code the way I did. So

How to Find Max and Min Quickly in Python List

Image
Here's logic to find Max and Min values in a List. Without using built-in Max() and Min () functions you can find Max and Min values in a List. For that matter, you need to write a user-defined function. This post is all about how to write it and run. Finding Max and Min in List You can achieve this by writing a user-defined function. Here's useful logic and steps to write it precisely. IN THIS PAGE Write a Function Execute Function Get the result Write Function You can write an user-defined function to get MAX and MIN values. In this function, I am using the max(), min() built-in functions. The other variables you can use as you wish. Below is the my actual logic. Sample Code def findmaxmin (data): ax = max (data) by = min (data) return (x,y) data = ( 109 , 98 , 88 , 7 ) (maximum, minimum) = findmaxmin (data) print ( "Maximum Marks = " , maximum) print ( "Minimum Marks = " , minimum) Created a Script Using vim editor Here as the first step, I

How to Write Class Object in Ubuntu Python

Image
Python supports object-oriented programming, which makes python powerful. Creating class in Ubuntu python explained. You can use it in different ways by assigning it to an object. Doing all these are explained in the below steps.   Writing Class in Python in 3 Steps Python code Write the code in script Execute script Writing Class in Python Below sample code my give indentation errors. However, I have corrected the code in the actual script. class Employee: """Base class""" empCount = 0 def __init__(self, name, salary): self.name = name self.salary = salary Employee.empCount += 1 # can also be written as Employee.empCount = Employee.empCount + 1 def displayEmployee(self): # function is defined here print "Name : ", self.name, ", Salary: ", self.salary # "emp1 is the first object of Employee class" emp1 = Employee("Akhil", 2000) # "emp2 is the second object of Employee class" emp2 = Employee(&quo

How to Read Kafka Logs Quickly

Image
In Kafka, the log file's function is to store entries. Here, you can find entries for the producer's incoming messages. You can call these topics. And,  topics are divided into partitions.

How to Check Kafka Available Brokers

Image
Here's the command to check the list of brokers present in a Kafka Cluster. You can say the Broker is the heart of the Kafka cluster. In simple terms, it works as a process. The main function is to receive messages from publishers and gives permission to access messages by consumers. How to Check Available Brokers in Kafka Here is the command: linux$  ./zookeeper-shell.sh zookeeper-IPaddress:2181 | "ls /brokers/ids" Just use the above command to get the number of brokers present in your host (Kafka Cluster). What is Default Broker-id in Kafka  The default broker id is -1 . When you create a new broker, it adds to -1. Then, it gives a new broker id. The broker ids will be generated from  reserved.broker.max.id + 1. Types of broker ids. Use assigned Zookeeper generated broker id. According to Wiki: Kafka runs on a cluster of one or more servers (called brokers), and the partitions of all topics are distributed across the cluster nodes.  Additionally, partitions are replicat

Here is Hadoop MapReduce DataFlow Tutorial

Image
Here are the six stages of MapReduce. The MapReduce is critical for your data processing needs. Traditionally, the whole file needs to read once then divided manually, but it is not convenient. With that respect, Hadoop provides the facility to read files (ignoring their size) line-for-line by using offset and key-value. MapReduce dataflow Quick Tutorial 1. Dataflow Diagram 2. MapReduce Stages MapReduce receives input and processes it. Here are the six stages of processing . It is helpful for your interviews and project. MapReduce Stage-1 Take the file as input for processing purposes. Any file will consist of a group of lines. These lines containing key-value pairs of data. The whole file can be read out with this method. MapReduce Stage-2 In the next step, the file will be in "splitting" mode. This mode will divide the file into key, value pair of data. This time key will be offset and data will be a valuable part of the program. Each line will be read individually so there