Import pandas aS PD Data=pd,read_csv(“ilename”) Create Dataframe from txt, file → import pandas as pd df= pd.read- table ("./ inputs/dist.txt", delim_whitespace= Thue, names ("A", "B", "C"))
Feature Series Objec t List
Data Structure 1D data structure. Can be 1D or mul -dimensional (using nested lists). Can have both numeric indexes and labels. Supports explicit Only numeric indexes are allowed. Supports implicit Indexing indexing, meaning you can programma cally choose, provide, indexing where indexes are automa cally assigned Type and change indexes. star ng from 0. Index Duplica on Indexes can be duplicate. Indexes cannot be duplicate. Element Homogeneous elements: All elements must have the Heterogeneous elements: Can store elements of different Type same data type (e.g., all integers or all strings). data types (e.g., a mix of integers, strings, etc.). Example Primarily used in Pandas for handling and analyzing data, Used as a basic data structure in Python for storing Usage where data is labeled. and accessing data.
S.No. Series Object Dic onary
1. It is essen ally a 1D data structure. Can be 1D or mul -dimensional with nested dic onaries as values. It can be thought of as similar to dic onaries, where Can be thought of as similar to a Series object, with keys 2. dic onaries store values against keys; Series stores values considered equivalent to indexes/labels of a Series object and against indexes/labels. values to Series elements. 3. Its indexes can be numbers or labels. Its keys can only be of immutable types (e.g., strings, numbers, tuples). S.No. Series Object 1D Ndarray 1. It stores homogeneous elements (same datatype). It stores homogeneous elements (same datatype). It supports explicit indexing, i.e., we can programma cally choose, It does not support explicit indexing; only supports 2. provide, and change indexes in terms of numbers or labels. implicit indexing with indexes star ng from 0. 3. It supports indexes of numeric as well as string types. It supports indexes of only numeric types. It can perform vectorized opera ons on two Series objects, even if their It can perform vectorized opera ons on two 4. shapes are different, by using NaN for non-matching indexes/labels. ndarrays only if their shapes match. 5. It takes more memory compared to a numpy array. It takes lesser memory compared to a Series object. Keys in a Database 1. Primary Key: o A primary key is a set of a ributes that uniquely iden fies each tuple within a rela on. No two rows can have the same primary key value. 2. Candidate Key: o A candidate key is any a ribute or combina on of a ributes that can serve as a primary key. In other words, it is a minimal super key, and there can be more than one candidate key in a table. 3. Alternate Key: o An alternate key is a candidate key that has not been chosen as the primary key. If a table has mul ple candidate keys, the ones not selected as the primary key are known as alternate keys. 4. Foreign Key: o A foreign key is an a ribute or a set of a ributes in one table that references the primary key of another table. It is used to establish a rela onship between two tables Querying Data SELECT * FROM Employees; SELECT DATE FROM Employees; SELECT DATE FROM Employees WHERE FirstName = 'Anna'; SELECT * FROM Employees LIMIT 5; UPDATE Employees SET LastName = 'Nayak' WHERE FirstName = 'Anna'; DELETE FROM Employees WHERE FirstName = 'Gandu';