Sometimes you need advice, Ask a teacher to solve your problems.

Sometimes you need advice, Ask a teacher to solve your problems.

Latest Posts

Monday, May 11, 2020

Create A DataFrame From A list Of Dictionary

CBSE COMPUTER SCIENCE AND IP

How To Create a DataFrame From a   list of Dictionary?

Create a DataFrame From  list of       Dictionary

We  can  create  the  DataFrame,  passing  the  Dictionary  as  an  argument  to  the  DataFrame. It is  very  easy  to  create  a  DataFrame from  a   list of Dictionary.






Example  1:

Lets take an example to create a DataFrame to pass the dictionary as an argument.

import numpy as np
import pandas as pd

dict = {
         'names'['Ankita','Subrat','Sarthak','Partha'], 
                      'physics':  [68,  74, 77, 78],
   'chemistry':  [84,  56,  73,  69],
   'IP':  [78,  88,  82,  87]}

#create dataframe using dictionary
df  =  pd.DataFrame(dict)

print(df)


Download the PDF to see More Examples:



Wednesday, May 6, 2020

Creating DataFrame From Dict Of Series

CBSE COMPUTER SCIENCE AND IP

DataFrame:
A dataframe is a two dimensional array like, pandas data structure that stores an ordered collections columns that can stores data of different types.
Major characteristics of a DataFrame data structure  are:
a) It has two indices or two axes –a row index (axis=0) and column index (axis=1).
b) A DataFrame is the combination of row index and column index .The row index is known as index in general and the column index is called the column_name.
c )The indices can be of numbers or letters or strings.
d)You can easily changes its values, i.e it is mutable.
e) You can easily add or delete rows /columns in a DataFrame.
f) There is no conditions for all the data are the same types across the columns.


Friday, April 24, 2020

Series

CBSE COMPUTER SCIENCE AND IP
Series:Creation of Series From - ndarray,Dictionary,scalar value,Mathematical operations,Head and Tail functions,Selection,Indexing and Slicing

Series:
Series is a one-dimensional labeled array capable of holding data of any type (integer,string, float, python objects, etc.). The axis labels are collectively called index.
pandas.Series
A pandas Series can be created using the following constructor −
pandas.Series( data, index, dtype, copy)





Read more ToDownload The PDF
 Series Download

Wednesday, April 22, 2020

Data Handling Using Pandas and Data Visualiation

CBSE COMPUTER SCIENCE AND IP
UNIT-1
Data Handling using Pandas-I
         i)Introduction to Python Libraries-Pandas ,Matplotlib

           Python library is a collection of functions and methods that allows you to perform many actions without writing your code. For example, the Python imaging library (PIL).is one of the core libraries for image manipulation in Python. 

❖ Python library-Matplotlib
Matplotlib is a part , rather say a library of python . Using Matplotlib you can plot graphs , histogram and bar plot and all those things .The matplotlib is a python library that provides many interfaces and functionality for 2D graphics similar to MATLAB in various forms.it provides both a very quick way to visualize data form Python and publication-quality figures in many formats. The matplotlib library offers many different named collection of methods, Pyplot is one such interface.


❖ Pandas: 
Pandas is an open-source, BSD-licensed (Berkeley Software Distribution) Python library providing high-performance, easy-to-use data structures and data analysis tools for the Python programming language. Python with Pandas is used in a wide range of fields including academic and commercial domains including finance, economics, Statistics, analytics, etc. Pandas builds on packages like NumPy and matplotlib to give us a single and convenient place for data analysis and visualization work.

     
 ii)Data Structures in in Pandas
        Pandas stands for “python Data Analysis Library”. pandas is fast, powerful, flexible and easy to use open source data analysis and manipulation tool, built on top of the python programming language.
Key Features of Pandas
    • Fast and efficient DataFrame object with default and               customized indexing.
  • Tools for loading data into in-memory data objects from different file formats.
• Data alignment and integrated handling of missing data.
• Reshaping and pivoting of date sets.
• Label-based slicing, indexing and subsetting of large data sets.
• Columns from a data structure can be deleted or inserted.
• Group by data for aggregation and transformations.
• High performance merging and joining of data.
• Time Series functionality.
Two main basic structure of pandas is :
• Series
• DataFrame
Series:
A series is a pandas data structure that represents a one dimensional array like object containing an array of data and an associated array of data labels called index. a)Size Immutable b)Values of Data Mutable
DataFrame:
A dataframe is a two dimensional array like, pandas data structure that stores an ordered collections columns that can stores data of different types.
Major characteristics of a DataFrame data structure are:
a) It has two indices or two axes –a row index (axis=0) and column index (axis=1).
b) A DataFrame is the combination of row index and column index .The row index is known as index in general and the column index is called the column_name.
c )The indices can be of numbers or letters or strings.
d)You can easily changes its values, i.e it is mutable.
e) You can easily add or delete rows /columns in a DataFrame.

f) There is no conditions for all the data are the same types across the columns.
                                                                     Download the PDF
                                  



Tuesday, April 21, 2020

SAMPLE QUESTIONS

CBSE COMPUTER SCIENCE AND IP
ALL THE SAMPLE QUESTIONS FOR INFORMATICS PRATICES

  
 1.Download 

2.Download 

3.Download

4.Download

5.Download

6.Download

7.Download

8.Download

9.Download

10.Download

11.Download

12.Download

13.Download

14.Download

15.Download

16.Download

17.Download

Thursday, April 16, 2020

CREATE DataFrame AND ACCESSING THE SUBSET OF DataFrame

CBSE COMPUTER SCIENCE AND IP

CREATE DataFrame  AND ACCESSING THE SUBSET OF DataFrame
Creating a Pandas DataFrame
 A Pandas DataFrame will be created by loading the datasets from existing storage, storage can be SQL Database, CSV file, and Excel file. Pandas DataFrame can be created from the lists, dictionary, and from a list of dictionary etc. Dataframe can be created in different ways here are some ways by which we create a dataframe:
1.Create a Pandas DataFrame from Lists
CODE1:
import pandas as pd
import numpy as np
# intialise data of lists of Samsung Products.
data = {
            'ITEM NAME':['Galaxy 5G', 'GALAXY S', 'GALAXY TAB S6', 'GALAXY A', 'QLED 8K'],
            'EXPENDITURE':[25000, 28000, 32000, 29500,45000],
            'ITEM CATEGORY':['SMART PHONE','SMART PHONE','TABLET','SMART PHONE','TV']                     
       }   
# Create DataFrame  #df is the object
df = pd.DataFrame(data)   
# Print the output.
df
output:
          ITEM NAME   EXPENDITURE ITEM CATEGORY                                      COLUMN NAME
____________________________________________
0
Galaxy 5G
25000
SMART PHONE
1
GALAXY S
28000
SMART PHONE
2
GALAXY TAB S6
32000
TABLET
3
GALAXY A
29500
SMART PHONE
4
QLED 8K
45000
TV




·         IF WE DONOT DECLARE INDEXES NAME THEN IT SHOWS BY DEFAULT STARTS FROM 0 TO ONWARDS




Code #2: Dataframe using list with index and column names:
import pandas as pd
import numpy as np
# intialise data of lists of Samsung Products.
data = { 'ITEM NAME':['Galaxy 5G', 'GALAXY S', 'GALAXY TAB S6', 'GALAXY A',
                      'QLED 8K'],
        'EXPENDITURE':[25000, 28000, 32000, 29500,45000],
       'ITEM CATEGORY':['SMART PHONE','SMART PHONE','TABLET','SMART PHONE','TV']
                       
       }
# Create DataFrame
df = pd.DataFrame(data,index=['a','b','c','d','e'])   
# Print the output.
df
output
          ITEM NAME   EXPENDITURE ITEM CATEGORY                                      COLUMN NAME
____________________________________________
a
Galaxy 5G
25000
SMART PHONE
b
GALAXY S
28000
SMART PHONE
c
GALAXY TAB S6
32000
TABLET
d
GALAXY A
29500
SMART PHONE
e
QLED 8K
45000
TV




Selecting/accessing a column:
v  Select one column using this syntax:
           <DataFrame object> [<column name>]
                             Or
           <DataFrame object>.<column name>
v  Select multiple  column using this syntax:
            <DataFrame object> [[<column name>,<column name>,……]]
Example:
From code#2
df [‘ITEM NAME’]
                             ITEM NAME
a
Galaxy 5G
b
GALAXY S
c
GALAXY TAB S6
d
GALAXY A
e
QLED 8K

df[[‘ITEM NAME’,’EXPENDITURE’]]
          ITEM NAME  EXPENDITURE
a
Galaxy 5G
25000
b
GALAXY S
28000
c
GALAXY TAB S6
32000
d
GALAXY A
29500
e
QLED 8K
45000
Selecting/accessing a subset from a DataFrame using Row/Columns Names
We can to select/acess a subset from a dataframe object:
syntax
<DataFrameObject>.loc[<startrow>:<endrow>,<startcolumn>:<endcolumn>]
v  To acess a single row,just give the row name/label at this
Syntax
df object.loc[<row label>,:]
Examples:
df.loc[‘d’]
v  To acess multiple rows
Syntax
<Dfobject>.loc[<start row>:<end row>, :]
Example
df.loc[‘a’:’b’, : ]
v  To acess selective columns
Syntax:
df.loc [:,<start column>:<end column>]
example:
df.loc[: ,’ITEM NAME’:’EXPENDITURE’]
v  To acess range of columns from a range of rows
Syntax:
<df object>.loc[<start column>:<end row>,<start column>:<end column>]
Example:
Df.loc [‘a’: ’b’,’ ITEM NAME’:’EXPENDITURE’]







Obtaining a subset/slice from a DataFrame using Row/Colmun Numeric Index/position
We can extract subset from dataframe using the row and column numeric index/position,but this time we will use iloc instead of loc means integer location.
Syntax:
           <df object>.iloc[<start row index>:<end row index>,<start col index>:<end col index>]
           Example:
         df.iloc[0:2,0:2]
v  Selecting/accessing Individual Value
Syntax
<dfobject>.<column>[<row name or numeric index>]
Example:
Df.ITEMNAME[‘a’]
     Questions:
v Create a DataFrame  object  df1 having an column name rollno, class, phone    number and indexes is Name of the students.

                                                     Download the PDF