Commands SQL, Python (BASICS)
Commands SQL, Python (BASICS)
LIST FUNCTONS
DICTIONAY FUNCTONS
ENUMERATE FUNCTION
It is used to display output with index. We can enumerate as list, tuple, set, dictionary.
******************************************************************************************
NUMPY
1. Import numpy as np
6. np.linspace () - A = np.linspace (1,100,12) # It returns evenly spaced values within a given interval.
np.linspace(start, stop , num=50, endpoint=True, retstep=True, dtype=None)
8. random() -
np.random.random(5) # It takes only one number x(5 here) & displays values equal to number quantity.
np.random.randint(5,20,4) # It displays given no. of values(4 here) between given input numbers 5 & 20.
np.random.uniform(1,5,50) # It displays given no. of unique values between given input numbers.
******************************************************************************************
PANDAS
For Importing The Data
2. df.nunique ( ) - df.nunique( ) # It shows the total no. of unique values in each column.
3. df.describe( ) - # For categorical dataframe, it will show a simple summary of unique values &
most frequently occurring values.
For Selecting The Data
1. df[[‘Col1’, ‘Col2’ , ‘Col3’ ]] # Selecting multiple Columns from the DF.
Adding / Removing
1. DataFrame - # To create a dataframe.
pd.DataFrame(data=, index=, columns= ) ,
pd.DataFrame( np.arange(1,10).reshape(3,3), index=[‘a’,’b’,’c’], columns = list(‘XYZ’)) ,
5. Removing Columns -
df.drop(‘Col_name’ , axis=1) ,
Date-Time
1. to_datetime ( ) - pd.to_datetime(DF.Date_Time_Col)
# Converts the data-type of Date-Time Column into datetime[ns] datatype.
3. From the Date-Time column, showing only hour, minute, month, weekdays -
df[‘Time_Col’].dt.hour ,
OTHERS
1. Dummies - df[‘Col_name ‘]= = ‘a’ # Creates dummy for level ‘a’ in True & False format.
6. DataFrame Profiling –
conda install -c anaconda pandas-profiling
import pandas_profiling
pandas_profiling.ProfileReport(df)
MATPLOTLIB
1. from matplotlib import style , style.use(“ggplot”) # For style purpose.
6. Scatter Plot - plt.scatter( x-elements, y-elements , color = ‘r’, s = 20 , edgecolor= ‘red’ . style='*-')
SQL
Types of Database:
Remove Database
CREATE DATABASE
CREATE TABLE
Delete Table
Describe Table
DATE
VIEW
A view is a virtual table, which contains rows and columns just like a real table.
Syntax:
CREATE VIEW view_name AS
SELECT
OPERATORS
AND OPERATOR
MAX – This function returns the largest value of the selected column.
Syntax: SELECT MAX (Col_name)
GROUPBY
It is used in SQL to arrange the identical data into groups with the help of some functions.
INNER JOIN
This type of join returns those records which have matching values in both tables.
Syntax:
SELECT Table1.Col1, Table1.Col2, Table2.Col1….
Syntax:
SELECT Table1.Col1, Table1.Col2, Table2.Col1….
LIKE OPERATOR