Skip to content

Instantly share code, notes, and snippets.

View sairamdgr8's full-sized avatar
🎯
Focusing

sai sairamdgr8

🎯
Focusing
View GitHub Profile
@sairamdgr8
sairamdgr8 / Sai-Working-with-window-functions-on-Dataframes-using-PySpark-series.py
Created February 25, 2024 10:24
Sai-Working-with-window-functions-on-Dataframes-using-PySpark-series.py
# Databricks notebook source
# Write a pyspark code to identify 𝒕𝒉𝒆 𝑯𝒊𝒈𝒉𝒆𝒔𝒕 & 𝑳𝒐𝒘𝒆𝒔𝒕 𝑺𝒂𝒍𝒂𝒓𝒊𝒆𝒅 𝑬𝒎𝒑𝒍𝒐𝒚𝒆𝒆 𝒊𝒏 𝒆𝒂𝒄𝒉 𝑫𝒆𝒑𝒂𝒓𝒕𝒎𝒆𝒏𝒕.
# COMMAND ----------
from pyspark.sql import SparkSession
from pyspark.sql.functions import min,max,col,rank,desc
from pyspark.sql.window import Window
@sairamdgr8
sairamdgr8 / Sai-Working-with-Lead-Lag-functions-on-Dataframes-using-PySpark-series.py
Created February 19, 2024 07:52
Sai-Working-with-Lead-Lag-functions-on-Dataframes-using-PySpark-series
# COMMAND ----------
from pyspark.sql import SparkSession
from pyspark.sql.functions import lead,lag,round
from pyspark.sql.functions import col
from pyspark.sql.window import Window
from pyspark.sql.types import *
# COMMAND ----------
@sairamdgr8
sairamdgr8 / Sai-Working-with-Complex-JSON-data-structure-using-PySpark-series-4 raw dataset
Created August 3, 2023 13:23
Sai-Working-with-Complex-JSON-data-structure-using-PySpark-series-4
[{
"name": "John Doe",
"age": 30,
"email": "john@example.com",
"address": {
"street": "123 Main Street",
"city": "New York",
"zipcode": "10001"
},
"phones": [{
@sairamdgr8
sairamdgr8 / Sai-Working-with-Complex-JSON-data-structure-using-PySpark-series-3 raw dataset
Created June 28, 2023 03:18
Sai-Working-with-Complex-JSON-data-structure-using-PySpark-series-3
{ "data": [
{
"MainId": 1111,
"firstName": "bunny",
"lastName": "dgr8",
"categories": [
{
"CategoryID": 1,
"CategoryName": "Example"
}
@sairamdgr8
sairamdgr8 / word-count-in-multiple-ways-in-python.py
Created May 24, 2023 15:44
word-count-in-multiple-ways-in-python
# Databricks notebook source
s="sai is a good boy sai is working in SG sai is a DE guy he has a pet called rocky he is having two laptops."
# COMMAND ----------
words_split=s.split(" ")
print(words_split)
letters_split=[]
letters_split[:]=s[:]
print(letters_split)
@sairamdgr8
sairamdgr8 / Sai_Joining_two_tables_Vetrically_when_no_common_column_is_invovled.py
Created April 28, 2023 06:18
Joining two tables Vetrically when no common column is invovled
# Databricks notebook source
from pyspark.sql import SparkSession
from pyspark.sql.functions import *
from pyspark.sql.types import *
from pyspark.sql import Window
# COMMAND ----------
spark=SparkSession.builder.appName("Joining two tables Vetrically when no common column is invovled").getOrCreate()
@sairamdgr8
sairamdgr8 / a-after-b-true-or-false-check-in-given-string-using-python.py
Created March 16, 2023 10:54
Sai-Working-with- a-after-b-true-or-false-check-in-given-string-using-python.py
s=input(str())
def a_b_occurence_check(s):
s1=[]
s1[:]=s
#s1
s1_a=[]
for i in range(0,len(s1)):
if s1[i]=='a':
s1_a.append(i)
@sairamdgr8
sairamdgr8 / Working_with_Json_data_using_pyspark_series-2.py
Created December 4, 2022 09:42
Working with Json data using pyspark series-2
# Databricks notebook source
## input
"""
{"id":"1","Name":"Sai"Ram","City":"Hyderabad"}
{"id":"2","Name":"Avi"nash","City":"Bihar"}
{"id":"3","Name":"Di"nesh","City":"Kurool"}
{"id":"4","Name":"Pramod"Kumar","City":"Mathura"}
#### output
{"id":"1","Name":"SaiRam","City":"Hyderabad"}
@sairamdgr8
sairamdgr8 / Sai-working-calculating-the-salary-credit-of-an-each-employee-with-their-attendance-using-Pyspark.py
Created September 10, 2022 03:14
calculating the salary credit of an each employee with their attendance using Pyspark
from pyspark.sql import SparkSession
from pyspark.sql.types import *
from pyspark.sql.functions import *
from pyspark.sql.window import *
spark=SparkSession.builder.appName("Sai-working-calculating-the-salary-credit-of-an-each-employee-with-their-attendance-using-Pyspark").getOrCreate()
Users = [("James","","Smith","36636","M",30000,{"22/06/2022":"leave","23/06/2022":"present"}),
("Michael","Rose","","40288","M",3000,{"22/06/2022":"present","23/06/2022":"leave"}),
("Robert","","Williams","42114","M",40000,{"22/06/2022":"present","23/06/2022":"present"}),
@sairamdgr8
sairamdgr8 / Sai-Working-find the biggest consecitve series from binary code -using-python.py
Created August 10, 2022 14:58
Sai-Working-find the biggest consecitve series from binary code -using-python.py
print("Input the binary code of 1's and 0's")
s=input(str())
print("Please press 1 or 0 to get their biggest series")
choose=input(str())
list_s=[]
list_1=[]
list_2=[]
for i_1 in s:
list_s.append(i_1)
list_s_index=[]