Skip to content

Instantly share code, notes, and snippets.

View anitaokoh's full-sized avatar

Anita Okoh anitaokoh

View GitHub Profile
sns.heatmap(df_new.corr())
#importing all the libraries needed
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
tips_df = sns.load_dataset('tips')
tips_df.head()
#.....read data
df = pd.read.csv(your_data)
#to select at numeric columns
df.select_dtypes(include=np.number)
#Wrapping it to a variable to get a new dataframe of other numeric features
new_df = df.select_dtypes(include=np.number)
import pandas as pd
website = 'url_of_choice'
website_table = pd.read_html(website)
df = pd.DataFrame(website_table[0])
INSERT INTO marvels VALUES(1, "Spider Man", 1, "Good", "Male", 1.78, 75.75, "USA", 4, 4, 3, 3, 1, 4);
INSERT INTO marvels VALUES(2, "Iron Man", 20, "Neutral", "Male", 1.98, 102.58, "USA", 6, 6, 5, 6, 6, 4);
INSERT INTO marvels VALUES(3, "Hulk", 18, "Neutral", "Male", 2.44, 635.29, "USA", 6, 7, 3, 7, 5, 4);
INSERT INTO marvels VALUES(4, "Wolverine", 3, "Good", "Male", 1.6, 88.46, "Canada", 2, 4, 2, 4, 1, 7);
INSERT INTO marvels VALUES(5, "Thor", 5, "Good", "Male", 1.98, 290.3, "Norway", 2, 7, 7, 6, 6, 4);
INSERT INTO marvels VALUES(6, "Green Goblin", 91, "Bad", "Male", 1.93, 174.63, "USA", 4, 4, 3, 4, 3, 3);
INSERT INTO marvels VALUES(7, "Magneto", 11, "Neutral", "Male", 1.88, 86.18, "Germany", 6, 3, 5, 4, 6, 4);
INSERT INTO marvels VALUES(8, "Thanos", 47, "Bad", "Male", 2.01, 446.79, "Titan", 6, 7, 7, 6, 6, 4);
INSERT INTO marvels VALUES(9, "Loki", 32, "Bad", "Male", 1.93, 238.14, "Jotunheim", 5, 5, 7, 6, 6, 3);
INSERT INTO marvels VALUES(10, "Doctor Doom", 19, "Bad", "Male", 2.01, 188.24, "Latveria", 6, 4, 5
CREATE TABLE marvels (ID INTEGER PRIMARY KEY,
name TEXT,
popularity INTEGER,
alignment TEXT,
gender TEXT,
height_m NUMERIC,
weight_kg NUMERIC,
hometown TEXT,
intelligence INTEGER,
strength INTEGER,
INSERT INTO tablename VALUES(column1_values, column2_values);
CREATE TABLE tablename(column_1 data type,
column_2 data type,
......);
SELECT name, SUM(intelligence + strength + speed + durability + Energy_projection + Fighting_skills) as Power_rate
FROM power_average
GROUP BY name
ORDER BY Power_rate DESC
LIMIT 5;
SELECT Name, CASE
WHEN intelligence > ( SELECT AVG(intelligence) FROM marvels) THEN 1
ELSE 0
END AS intelligence,
CASE
WHEN Strength > ( SELECT AVG(Strength) FROM marvels) THEN 1
ELSE 0
END AS Strength,
CASE
WHEN Speed > ( SELECT AVG(Speed ) FROM marvels) THEN 1