1) Setting up variables

a=5
b="Raj" # Strings are defined in quotation
print(b)
"Raj"

2) Basic operators -,+,*,/,min,max

a=5
b=7
c= (a+b)/(b-a)
print(c)
6

min(a,b)
5

max(a,b)
7

+(a,b)
12

3) Power function

a=2^2
4
b=2^3
8

4) Creating sequence of numbers

>collect(1:5)
1
2
3
4
5

5) Creating sequence with steps

# collect(start:steps:end), so after the starting point,
# it will keep jumping 2 steps and print the values till the end point.
>collect(1:2:10)
1
3
5
7
9

6) Fundamental Commands

a=2.3
round(a) # rounding a to closest floating point natural
2.0
ceil(a) # round up
3.0
floor(a) # round down
2.0
trunc(a) # truncate toward zero
2.0

7) Arrays

myList=[1,"Star",2,3,4]
#List is heterogenous as it can hold neumeric and strings together.
1
"star"
2
3
4

# Indexing of arrays, unlike Python, Julia indexing starts with 1
myList
"star"
myList
3

# Accessing the last element in the list.
myList[end]
4
myList[end-1]
3

# To check the number of elements in the list.
length(myList)
5

#The basic operators to manipulate vectors include:
a=[9,5,7,1,2,8]
sum(a)
32
maximum(a)
9
minimum(a)
1
sort(a)
1
2
5
7
8
9

# union of two arrays
a=[1,2,3,4,5]
b=[4,5,6,7,8]
union(a,b)
1
2
3
4
5
6
7
8

intersect(a,b)
4
5

using Pkg # To read the csv file, we have to call the libraries using "using" command
using CSV # To know the dimesions of the dataset.
size(df_data)
(93, 4)

# To check the column names.
names(df_data)

"Manufacturer"
"Model"
"Type"
"Price"

# To check description of the data or to get insight of the data.
describe(df_data) # To select single column. Here we are selecting only sepal length.
df_data[:sepal_length] # To check first 5 lines of the dataframe. Similar to head command in python and R
first(df_data,5) # To check last 5 lines of the dataframe. Similar to tail command in python and R
last(df_data,5) # To check the unique values of a column.
unique(df_data[:species]) # Selecting multiple columns.
df_data[ [ "sepal_length" , "species" ] ] # Selecting rows and multiple columns.
# The left side of the comma is for the selection of rows and the right side is for selection of rows.
df_data[ [2,5,9] , [ "sepal_length" , "species"] ] # Selecting sequence of rows and multiple columns.
df_data[ 1:20 , [ "sepal_length" , "species" ] ] # Specifying sequence of columns and rows with numbers.
df_data[ 1:15 , 2:4 ] # Specify columns and sequence of rows with numbers.
df_data[ 1:15 , [1,2,4,5] ] # Applying condition on rows. Selecting only the rows for the column species having the value "setosa".
# the colon ":" on the right after comma is asking to give all the columns df_data[ df_data[:species].=="setosa" , : ] # Applying multiple conditions on rows. Using & operator to ensure both the condition is satisfied .
df_data[ ( df_data[:sepal_length].>5.5 ) .& ( df_data[:species].=="setosa" ) , : ] # Applying multiple conditions on rows. Using (or) ! operator to ensure both the condition is satisfied .
df_data[ (df_data[:sepal_length].>5.5) .| (df_data[:species].=="setosa") , : ] 