Boolean and Sets

Boolean and Sets In this tutorial we shall discuss about Boolean and Sets. Topics we have discussed in previous tutorials: Dictionaries Functions of dictionaries Tuples Functions of tuples Sets Few important functions of sets Boolean: Boolean are the expression such as True, False. These are used to test the data whether it is correct or wrong.              E.g: If we type 1 == 1 as code, we know this value is correct and run the code we get True. E.g2 : If we type 1 == 5 as code, we know this value is correct and run the code we get False . This is the basic applications of Booleans. Now lets continue with some complicated data types in python. and: If we use this keyword between two conditions and two of the conditions are true then the value will be true or else for any other case it will be false. We also can use this between multiple conditions. Condition 1 Condition 2 Output True True True True False False False True False False False False or: If we use this keyword between two conditions and two of the conditions are true then value will be true or else for any other case it will be fasle. We also can use this between multiple conditions. Condition 1 Condition 2 Output True True True True False True False True True False False False These are two important Booleans we will be using very regularly in data manipulation techniques. Application of Boolean: To check whether an item belongs to the list or not.                                                                                                  To check we have to write: element in the list. Decision Making in Python: Checking a condition and making the correct decision ( here correct means given by programmer ) is known as decision making. if statement: This is a decision-making statement, where a condition is given to it and asked for a decision.             Syntax: else statement: This statement is used for only other than condition after if statement. elif statement : This statement is used for multiple conditions other than if condition . If any query in this tutorial let us know in the comment section. Topics we will cover in the next tutorial: Iterations For loops While loops Range List comprehension For more information visit the section of Data Science.

Mapping Cardinalities, Relationship, ER-Diagram

Mapping Cardinalities, Relationship, ER-Diagram Mapping Cardinalities In this tutorial, we shall discuss the Mapping Cardinalities, Relationships and ER-Diagram. There are four different types of mapping cardinalities. They are: One to One:  If we consider the two sets A&B. The entity in A associated with at most one entity in B and in the same way, one entity in B is associated with the at most one entity in A. One to Many:  In the consideration of two sets A&B. The entity in A associated with one or more than one entity in B, however every entity in B associated with at most one entity in A. Many to One:  The entity in A associated with at most one entity in B, but every entity in B is associated with one or more entities in A. Many to Many: An entity in A associated with one or more than one entity in B and similarly, the entity in B associated with one or more than one entity in A. Relationship: A relationship is an association among several entities. Relationship Set: A relationship set is a set of relations of the same type. It is a mathematical relation on n>=2 entity sets. Entity 1 – Student(roll, name, age) Entity 2 – Book(bkno, author, subject) The relation can be between the student to the book taken from the library Relation set can be –  issue(roll, bkno) Having two entities in a relationship is known as binary relationship, three entities is known as ternary relationship and n entities is known as n-ary relationship Entity – Relationship Diagram (ER Diagram) ER diagram is a graphical representation of the logical structure of the database. ER Diagram consists of the following components: Rectangles – denotes the entities Ellipse – denotes the attributes Diamonds – denotes a relationship Lines – denotes links between attribute, relationships and entities Double Ellipse – denotes the multi-valued attribute Dashed Ellipse – denotes derived attribute Double Lines   – denotes total participation that is the merging between relationship and entity Double Rectangles – denotes the weak entity set (set with a partial key without primary key) For more information visit the section of SQL.

Types Of Keys

Types of Keys There are many types of keys associated with database management. Out of that, the most important and necessary keys are discussed in this tutorial Super Key: A combination of one or more attributes, with which we can uniquely identify a particular entity is known as a super key. For Example: If we consider the student schema as student(roll no,name,sex,salary,age,address,class,section) (class,section,roll no) (class,section,roll no,sex) (name, address) are the list of superkeys, that can uniquely identify the student. Candidate Key: The candidate key can be defined as the minimal super key. From the above example, we can say that (class, section, roll no, sex) will be the candidate key with minimal superkey, ensuring the sufficient and essential attributes to uniquely identify the entity. Similarly, name and address can also be identified as a candidate key. Primary Key:  Out of the identified candidate keys, implemented candidates can be called as the primary key. From the above example (class, section, roll no) can be implemented as a primary key. Alternate Key: The unimplemented candidate key is known as alternate key. So, from the above example (name, address) can be known as the alternate key. Foreign Key: The attribute which is a prime attribute in one table but non-prime attribute in another table is known as the foreign key. For example: If we consider the tables in a university database Student(roll, name, sex, age, address, class, section) Department(deptno, deptname) Teacher(tno, tname, tage, deptno) Dependent(empno, dependentname, relation) Employee(empno, empname, age, sex) Out of the above tables, the underlines attributes are called the prime or key attributes and the remaining are known as non-prime attributes. In the above database, the deptno is the foreign key in the Teacher table with deptno as a prime attribute in the Department table. When a foreign key occurs then domain constraint comes into play. It means that the set of values assigned for the primary key in both the tables must be in the same domain. Partial Key:  The attribute which can relate the set of tuples, if no primary key is identified. In the above database for the Dependent table, empno can be known as the partial key. Secondary Key:  The secondary key is mainly used for the Indexing, for better-searching performance. Unique Key: The unique key must be unique to be identified and cannot be updatable but it can be null. Surrogate Key: This is known as the unique key to be identified and can be updatable but the null value is not allowed. Composite Key: If any primary key made up of more than one attribute then it is known as a composite key.  For prime attribute, not null, non-updation constraints will be applicable. This is all about the types of keys. Visit the sections of Data Science for more information.

Data Abstraction Users, Models and Languages

Data Abstraction, Users, Data Models and Languages In this tutorial we will discuss about the concepts of data abstraction, users of the database, database models and introduction to data languages. Data Abstraction Data abstraction shows how the data is stored from the low-level to the high-level. In this data abstraction three levels are there: Physical Level: This level shows how the data is stored in the database from the low to complex level data structures. Logical Level:  This level describes what sort of data is stored and the relationship among the data that is present in the database as simple structures. View Level: It is the highest level of the data abstraction visible to the user. It is only a specific part out of the entire data visible to the user that can be accessible by the user. Instances and Schemas Instance: The time interval in which the content present in the database is known as the instance of the database Schema:  The logical description of the database that stores the data is known as the schema. Physical schema and logical schema are the two types that describe the physical and logical levels in Data Abstraction respectively. Database Users Naive Users:  The users interacting the database using the application program are known as the naive users Application Programmers:  They are interacting the database by writing the programs to interact with the database Sophisticated Users:  They can directly interact with the database and can change the database accordingly. Specialized Users:  These users will use the database for the sake of a particular purpose or application. Data Models It defines the structure and is a tool to describe the data, relationships with the constraints of the database as discussed in Data Abstraction  The most used data models are: Relational Model:  In this model, the data and the relationship among the data are stored in the tables. Entity-Relationship Model:  The entity will have permanent existence in the database with particular attributes and can be identified uniquely. The relationships between the entities will be present in this model. Database Languages There are 4 different database languages with the following set of commands associated with each language. For more information visit the section of SQL.

Database Management System Introduction

Database Management System Introduction This tutorial is a start about the introduction to database management system and acid properties. Database management is a process to store the data, retrieve the data, and perform the manipulations on the data with proper security. Traditionally data is stored in the file formats, but it is hard to obtain the data from the file and to perform the operations. To solve the problem with data storage, database management has come into play as an effective data storage system. Database Terminologies Database  It is the electronic storage point where the data is stored in database management system. It is a vast store point. Entity It is an object and can be recognizable in an easy way. If a university database is considered the professors, hods, students, etc are known as the entity. An entity set is the combination of all the entities is a single set.  Attributes It is the characteristic of describing the entities in database management system. The attributes have a special character and are similar to all the entities. For the university database, the professor as an entity attributes like age, name, gender, etc are the attributes and have the specific values to be stored.  Database Applications – DBMS And much more… ACID Properties – DBMS Atomicity It is the property of completing the transactions, completely in database management system. This property of the database makes the actions to be performed completely or left as uncompleted. If any database transaction is stopped in the middle, without completion, due to power problems, errors, and crashes, it is very important to update the state of the transaction. So, this property of atomicity makes the transactions as successful if all the actions are performed correctly, else mark as a failure, and do not proceed with any changes in the transaction. Consistency This property ensures that the data storage transaction is done accordingly, without affecting the constraints and any changes to the database relationship. This ensures that the data written to the database is done properly by maintaining all the rules and constraints and as a legal transaction. Isolation This is an important property of the database management ensures that if multiple transactions are done to the database at the same time, isolation property applies them one after the other sequentially, thus makes the database stable and secured with proper transactional changes. Durability This property ensures that the changes done by the transactions to the database are to be committed if any power failures or crashes happen. This shows that the storage of data in non-volatile memory with the transactional changes ensures durability. SQL – DBMS SQL stands for Structured Query Language, used as the computer database language for the relational database management system. SQL can be used as a communication protocol for the data storing, retrieving, and manipulations on the database. In the further tutorials, the commands in the SQL programming to work on the database systems are discussed briefly with working explanations. Work on these tutorials, to complete the working on the Relational Databases with Mysql, PL SQL, and much more. For any kind of doubts in this tutorial, can type them below in the comment box and further continue to another tutorial.

Dictionaries and Tuples in Python

Dictionaries and Tuples in Python In this tutorial we shall discuss about the dictionaries and tuples in python. In the previous tutorial we have discussed: What is List? Functions that can be useful in Lists. In this tutorial, you will come to know clearly about Dictionaries and Tuples. In general, the dictionaries are a type of data structure that has key values and many and Tuples is also a data structure that is similar to lists. Dictionaries:                    A dictionary is a data structure that has key values and some mapped values to each of the keys. It is also known as hashes. These keys and mapped values could be any data type in python.             E.g: my_dictionary= { ‘key1’:1, ‘key2’:2, ‘key3’:3} To access the elements, We have to give key value as argument to the dictionary name. my_dictionary[0]          #giving such values will give us an error  my_dictionary[‘key1’] #value respect to key1 will be printed Updating a dictionary: As we know that dictionaries are mutable and we can add, remove or interchange the values. Operations can be performed on dictionaries: Some of the functions were discussed in the previous article, click here to go there fromkeys(): This is a function to create a new dictionary using sequences, lists or other data structures. get(): This function is equivalent to accessing a value using label indexing.   My_dict[‘name’] == My_dict.get(‘name’) This function doesn’t give an error when an undefined key is given as an argument. items(): This function gives all items (keys and values ) in a clean arranged way. update(): This function is to add items in a dictionary from another dictionary. values(): This function is to display all values of a dictionary. Lists in a dictionary: A list can be assign as a value in a dictionary. my_dict={‘students’:[‘vineet’,’harsh’,’vijay’],’marks’:[34,45,75]} Tuples: A tuple is a data structure similar to lists, but it is immutable, it values cannot be changed. Tuples in python use parenthesis where a list uses square brackets. E.g: my_tuple = (‘a’, ‘b’, 5) Basic operations on tuples: len(my_tuple)  # Returns the number of elements in the tuple max(my_tuple)  # Returns the maximum value of tuple, only when the elements of the tuple are of the same data type min (my_tuple)  # Returns the minimum  value of tuple, only when the elements of the tuple are of the same data type 3*(my_tuple)  # triples all the elements present in the tuple tuple(seq)        # converts a list into the tuple important: Format is a very important function, where it identifies {} and fills them according to given arguments. Set: It is a data structure in python which holds only unique values. A set is defined between curly brackets             E.g: my_set= { 4 ,35 , 53, 353,66, 35 ,23 ,35 } As the definition of a set says that it can hold only unique values but we have given multiple same values. Let us see what output we get Multiple values are removed and only one value is kept in the set. set(): This is known as the set function which converts a list, sequence, or other forms of collected data into a set form of data. Few Operational  functions used for sets. Add(): Add an element to the set. intersection(): This function finds the intersections of two sets. issubset(): This function takes an argument of another set and checks whether it is a subset of this set or not. isdisjoint(): This function says whether the two sets have any common elements or not. If the output comes to be true, it means both the sets have null intersection. What is True and False ,will be discussing in upcoming tutorial. This is the end of this tutorial about dictionaries and tuples in python. For more information visit the section of Data Science.

Lists in Python

Lists in Python Topics covered in the last tutorial, Basics of Strings and Arithmetic Calculations. In this tutorial we will be discussing about the lists in python. Lists: Lists are a type of data structure in python, which can hold different forms of data types( int, float, char…. ) unlike in other programming languages. Each element in a list is known as “item”. Each item is separated by a comma (,) and if the item is a character it should be enclosed within apostrophe and integers can withstand alone. All the items should be enclosed within square brackets[]. Lists are mutable which means, the programmer can add, remove, interchange the values in a list. E.g: our_list = [1,’a’,2,’b’]             This is list of 3 items in it. my_list = [1,’a’,2,’b’]    #declaring a list my_list #accessing a list [1,’a’,2,’b’] #output print(my_list) #accessing list in another way [1,’a’,2,’b’] #output #Indexing and slicing of list and their outputs my_list[0] >> 1 my_list[-3] >>’a’ my_list[:] >>[1,’a’,2,’b’] my_list[-3:] >>[‘a’,2,’b’] Operations on Lists: To perform changes in a list, We have to type the list name and put a dot (.) after it and should hit TAB button. append(): This function takes an item as an argument as adds that in the list at last position.            For example my_list.append(7)   then my_list = [1, ’a’, 2, ’b’, 7 ] , this would be the final list. clear(): This function would clear all the elements of the list and a null list will be created on the same name.    For example: my_list.clear()          then my_list = [ ] , this would be the final list. copy(): This function creates a duplicate copy of the list. count(): This function takes an argument element that is present in the list and gives the number of times that particular element is repeated in that list. For example my_list.count(1)   #(my_list = [1, ’a’, 2, ’b’, 7 ]) then the output would be 1. extend(): This function takes the argument as the name of other list and the other list items can add to present list. For example: other_list = [4, ‘gd’ ,6 ]                                my_list.extend(other­_list)                                           then my_list = [1, ’a’, 2, ’b’, 7, 4, ‘gd’ ,6  ]  , this would be final list. index(): This function takes the argument as one of the elements of the list and gives its index value. If the given element is recurring many times in the list, then the first index value will be as output. For example: my_list = [1, ’a’, 2, ’b’, 7, 4, ‘gd’ ,6  ]         my_list.index(7)                                          4         #this will be output insert(): This function takes two arguments, the first argument is the position where you wanted to insert the element, the second argument will be the element that we wanted to insert in the list. pop(): This function is also useful in many other programming languages which means remove. This function removes the last element of the list. This function also works in other way, give any index number as function argument and this function would remove the particular element that belongs to that index value. remove(): This function removes the element which is given as argument. reverse(): This function reverses all the elements of the list. Sort(): This function only works when all the elements of the list are of same data type. This function sorts the elements either from ascending to descending or in reverse order according to user guidance. Nested list: A nested list is a list that contains a list as its element. E.g: my_list = [1 , 4, 5, [‘a’, ‘b’ ,’c’ ]] Accessing elements in a nested list: To access ‘b’ from the above example                            my_list[3][1] If you are new to Python. You can check out the previous article to cover the basics: Click Here. Things we shall cover in next tutorial: Dictionary Tuples This is all about this tutorial lists in Python. For more information visit the Data Science section.

Basics of Python

Basics of Python Small announcement for upcoming tutorials: We will have a general overview of python programming language. The requirement to proceed further is to have basic knowledge about programming, if not please check out the course – Click Here. If you are much aware of the python programming language and about the basics of python you can skip all these python tutorials. The content we will be covering in python for Data Science and Machine learning: Data Types In Data Types: Numbers Strings Printing Lists Dictionaries Booleans Tuples Sets Comparision Operators If, elseif, else Statements For Loops While Loops range() List Comprehension Functions Lambda Expressions Map and Filter Methods Data Types (Python) Basic arithematic operations- 2 + 5 # In python to add numbers just put + sign in between operands 5  #output 2 – 5 # subtract second number from first -3 #output 10/2 # division of two numbers 5 #output 11 % 2 # this is known as modular division where remainder is returned 1 #output 5**2 # exponential manipulations ( 5 to the power of 2 )  25 #output 5 + 7 * 2 + 4 # Python will multiply the numbers first and next addition 5 + 14 + 4 23 #output (2 + 3) * (5 + 5) # if we want to make additions first then we have to put them in parenthesis 50 #output Assigning some value to a variable : The variable name should follow some rules It shouldn’t start with a numeric digit. And shouldn’t have any special characters other than “_”. It should not consist of spaces in between, Use “_” for word separation. Defining a String: A string (combination of alphabets and numeric digits ) must be defined in between of  “string” or ‘string’. String1= “Robotic electronics” # defining a string String2= ‘Robotic Electronics’ #defining a string Now once a string is defined , we will be learning how to access a string, There are two ways to access a string. String1 # write the variable name ‘Robotic electronics’ # string output , or else the other method is print(String1) # write the variable name inside a print statement Robotic Electronics There is a difference between two methods: 1. There is Out[13]: display , when we use to access a string directly and the string   is displayed inside ‘’ 2. accessing the strings using print statement is meant to be better way of display. Indexing and Slicing : Once we define some data, then the major part of our job is left which is accessing the data in different forms. Let us explore few of them. Indexing: Accessing one of the character or integer value from the string is known as indexing. In python , indexing starts with “0” and from the last indexing starts from “-1”. Let’s see some codes in jupyter notebook. String = “Robotic Electronics” print(String) Robotic Electronics #output String[0] ‘R’ #output String[7] ‘ ‘ #output String[-1] ‘s’ #output print(String[0]) R #output print(String[7])           # here is a space  output print(String[-1]) s #output Adding two strings: Let’s assume we have multiple strings and we wanted to combine all the strings in a single string. E.g: “robotic’  and ‘electronics’ are the two strings that we wanted to add by giving a gap between them. Then simply type                    ‘robotic’ +   ‘  ‘   +   ‘electronics’ Slicing: In Indexing, we have to learn how to access single elements. In slicing, we will learn how to access more than one element from a string. Here we will be using colon (:) to perform such actions. We will indexing one number before the colon, which means from that point to the index that is used after the colon. Few Operations that can be performed on strings. Let’s assume we are having a string String_1= ‘Technologies we cover are “data scince” “Arduino” “IoT” “Robotics” “Electronics”‘. >> String_1.lower( )  #this will covert all the characters to lower case alphabets. >> String_1.upper ( )  #this will covert all the characters to lower case alphabets. >> String_1.split ( )  #this will split the string with respect to space that means wherever there is a space between the characters. >> String_1.split (‘o’ )  #this will split the string with respect to the character ‘o’. String = “Robotic Electronics” print(String) Robotic Electronics #output String[0:3] ‘Rob’   #output String[-4:-1] ‘nic ‘ #output Things that we have covered in this tutorial about the basics of python are: About arithmetic operations String creation and display Indexing Slicing In upcoming tutorials we will learn about: Lists Dictionaries Tuples and sets And will continue our python crash to course to master in Data science and machine learning This is all about the basics of python. If you are new to this tutorial you can check the previous tutorial for better understanding – Click Here. Any queries let us know in comment section.

Getting Started with Data Science

Getting Started with Data Science In this complete tutorial, you will complete the course of Data Science. Data Science is all about using data to solve problems. Many people have a doubt why is data science so important? It is important as the fundamental goal of data science is to help companies to take quick and smarter decisions that help them to be the top of their market. As per the analysis, the number of companies using data science is increasing. So, start this to become a Data Scientist. What will you learn in the complete course? Python Numpy Pandas Matplotlib Seaborn Data Visualization Geographical Plotting Machine Learning Intro Linear Regression Logistic Regression K Nearest Neighbors Decision Trees Much More. So, In this tutorial let’s start with Python. The reason why python is one of the most powerful languages and why Python is more popular is because of its hundreds of add on libraries that help in data manipulation in data science, machine learning, and much more. There are many ways to download python on your computer system, but the best way is to download full ANACONDA installation. Python is much more than just a python standard library. ANACONDA is one of the most powerful tools to perform data manipulation techniques for different usage. Here to master in PANDAS, we will be jupyter notebook to learn and practice the things. Jupyter notebook is a part of anaconda library. There is a very good thing about this tool, which is an open platform for individuals to work on and explore. Other tools in ANACONDA Jupyterlab Jupyter Notebook (This would be used in all the tutorials) Powershell prompt Pycharm Qt Console Spyder Glueviz Orange 3 RStudio How to download ANACONDA To dowload ANACONDA on your system, follow the steps: Click here to open “Anaconda.com” – Open. Now, go to the Products > Individual Edition. Click on the Download and it’s a bit big file (466MB) so it takes time for completion of the download. Once the installation is done, we shall move to the next step in learning the pandas library. The next step you need to do is opening a Jupyter Notebook. Open ANACONDA Navigator in your system. Next launch Jupyter Notebook Open the Jupyter Notebook, the dashboard would look as shown below: The files represented in the above picture are your recent files that you have worked in jupyter notebook. These files are stored in a cloud storage. 4. Open an empty file to write down our first python for data science and machine learning Code. Once you click on the Python 3, the screen will be as shown below.   Red part- The cell – where you need to write the python code. Green part- output or errors of the program ar The black arrow shows “LOGOUT”, by clicking which you can exit from the jupyter notebook. Important Tips for Beginners Click on Untitled text to change the file name that you are working in Next, click on the first tool in Redbox to save the file ( although mostly everything will save automatically ) Click on file, to open a new notebook, to copy the notebook, rename, and few basic changes. The place enclosed within the blue box is known as a CELL, where we write our code. Click on Edit option, copy the cells, move and remove the cells, and make few changes to the notebook cells. To run and execute a code click the “RUN” option on the top or simply press “ SHIFT + ENTER” keys on your keyboard. Conclusion I hope you understood clearly how to download ANACONDA and a bit about Jupyter Notebook is covered. Please feel free to ask doubts in the comment box below. You will learn the Basics of Python and Python for Data Science in the next tutorial.