Skip to content

Instantly share code, notes, and snippets.

View AayushSameerShah's full-sized avatar
🤨
Hmm...

Aayush Shah AayushSameerShah

🤨
Hmm...
View GitHub Profile
@AayushSameerShah
AayushSameerShah / viewes_sql.md
Created December 8, 2021 14:02
The go to list with views

Simple creating views

-- General Syntax
CREATE VIEW view_name AS
<SELECT QUERY>

Alter viewes

CREATE OR REPLACE VIEW view_name AS 
@AayushSameerShah
AayushSameerShah / case_in_sql.md
Last active December 8, 2021 11:16
This file is dedicated to the case statement only

There are 2 types of CASE:

  1. General CASE
  2. CASE expression

General Syntax

-- General Syntax
CASE
    WHEN condition1 THEN result1
 WHEN condition2 THEN result2
@AayushSameerShah
AayushSameerShah / easy_points_for_sql.md
Last active December 8, 2021 12:07
This will show some points to remember in SQL or to reference when needed

1. There are 2 constraints which might help

  1. CEHCK
  2. EXCLUDES
-- CHECK
CREATE TABLE table_a
(
@AayushSameerShah
AayushSameerShah / SQL_exclude_intersection.sql
Created December 6, 2021 17:14
The SQL statement to exclude the intersection of full outer join
SELECT *
FROM table_A
FULL OUTER JOIN table_B
ON table_A.col = table_B.col
WHERE table_A.col IS null
OR table_B.col IS null
@AayushSameerShah
AayushSameerShah / count_nouns.py
Created September 27, 2021 18:28
This will give the list of words tagged by part of speech directly! Amazing! #NLP
tokens = nltk.word_tokenize(text.lower())
text = nltk.Text(tokens)
tags = nltk.pos_tag(text)
@AayushSameerShah
AayushSameerShah / single_legend_multiple_plots.py
Created September 25, 2021 16:32
This is how to put the single - common legend when you have made a single plot with multiple axes.
handles_0, labels_0 = axes[0].get_legend_handles_labels()
handles_1, labels_1 = axes[1].get_legend_handles_labels()
handels = handles_0 + handles_1
labels = labels_0 + labels_1
fig.legend(handels, labels, loc=(0.83, 0.85))
"""Here, the main function is `.get_legend_handles_labels()`
it will return the labels and handles for individual plots
@AayushSameerShah
AayushSameerShah / show_pipeline_diagram.py
Created September 20, 2021 09:32
This will help us to visualise the pipeline
from sklearn import set_config
set_config(display='diagram')
pipeline
@AayushSameerShah
AayushSameerShah / make_new_feature.py
Created September 6, 2021 07:16
This will get correlation with the features and will return the correlated DF. Please update the column names.
def new_ft(operation):
ft = {}
for i in range(len(num_features)):
for j in range(i+1, len(num_features)):
ft1 = num_features[i]
ft2 = num_features[j]
oparated = eval(f"combined_xy[ft1] {operation} combined_xy[ft2]")
corr = oparated.corr(combined_xy["co2"])
ft[f"{ft1} {operation} {ft2}"] = corr
ser = pd.Series(ft)
@AayushSameerShah
AayushSameerShah / remove_legends_seaborn.py
Created September 6, 2021 07:13
Just remove the daunting legend from seaborn plot.
# For most plots
plt.legend([], [], frameon=False);
# For pairplot
temp = sns.pairplot(...)
temp._legend.remove()
@AayushSameerShah
AayushSameerShah / numpy_triu.py
Last active June 30, 2022 06:20
This will make a mask for heatmap. (TRIANGLE HEATMAP)
plt.figure(figsize=(10, 6))
corr = df.corr()
mask = np.zeros_like(corr)
mask[np.triu_indices_from(mask)] = True
sns.heatmap(corr, mask=mask, square=True, cmap="Blues")