Posts

Showing posts from February, 2021

Pandas Basic Tutorial

Image
DEMO Note: This was made by the Stackoverflow Developer Dataset . *import pandas as pd   df = read_csv(“file path”) # reads the CSV file  df  #prints the entire data frame. df.shape #gives the shape of the data frame (rows, columns) df.info #gives the complete info about the data frame pd.set_option(“display.max_columns”, number of columns) # displays all the columns. pd.set_option(“display.max_rows”, number of columns) # displays all the columns. schema_df = pd.read_csv(‘file path_schema.csv”) #gives what the each column mean df.head() #displays first 5 rows by default  df.head(10) # displays first 10 rows df.tail() # displays last 5 rows  df.tail(10) #displays last 10 rows DATAFRAME AND SERIES We can create a data frame with the help of dictionaries. people = {“First”:[‘Corey’, ‘jane’, ‘Jhon’]                  “Last”:[‘Schafer’, ‘Doe’, ‘Doe’]                  “Email”: [‘Corey@gmail’, “Jane@gmail”, Jhon@gmail”]}   Keys are columns, Values are rows. There are two data types in pandas:

Numpy-Basic Tutorial(Linear Algebra)

Image
*import NumPy as np NumPy stands for Numerical Python  It is a fundamental python package for scientific computing  Can be used for arrays, Linear algebra, Random Numbers, Broadcasting a= np.array([3,6,9,12])  #print the array. a/3 # divides all the elements in the array and prints float values Array: it is collection of elements of same data type Create arrays from lists or Tuples Array() np.array(object, dtype, copy. order, subok,ndmin) #internal parameters np.array([1,2,3]) #1d array np.array([1,2,3.0]) # 1d array with different data types, also called upcasting np.array([[1,2],[3,4]]) #2d array, nested list np.array([1,2,3], ndimn=2) # prints 2d array without nested list np.array([1,2,3], dtype=complex) #changes the data type, prints complex values Arange(): creates an array of evenly spaced values. np.arange([start].stop.[step], dtype=None) #includes start value but excludes stop value np.arange(1,10) # prints array of 1-10, since we didn’t gave step value it takes step as 1 np.ar