0% found this document useful (0 votes)
3 views9 pages

Informatics Practices Project

The document contains a series of Python programs demonstrating the use of the Pandas library for data manipulation and analysis. Each program showcases different functionalities such as creating Series and DataFrames, handling missing values, and modifying data. The outputs illustrate the results of the operations performed in each program.

Uploaded by

bijya29rawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views9 pages

Informatics Practices Project

The document contains a series of Python programs demonstrating the use of the Pandas library for data manipulation and analysis. Each program showcases different functionalities such as creating Series and DataFrames, handling missing values, and modifying data. The outputs illustrate the results of the operations performed in each program.

Uploaded by

bijya29rawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

PROGRAM-1

INPUT :

import pandas as pd

import numpy as np

ob = pd.Series([16, 5, np.nan, 2,34])

print(ob)

OUTPUT :

0 16.0

1 5.0

2 NaN

3 2.0

4 34.0

PROGRAM-2
INPUT :

import pandas as pd

series2=pd.Series(["kavi", "Ravi", "Rummy"], index = [3,5,1])

print(series2)

OUTPUT :

3 kavi

5 Ravi

1 Rummy
PROGRAM-3
INPUT :

import numpy as np

import pandas as pd

dict1={'INDIA':'NewDelhi', 'UK':'London', 'JAPAN':'Tokyo'}

print(dict1)

OUTPUT :

{'INDIA': 'NewDelhi', 'UK': 'London', 'JAPAN': 'Tokyo'}

PROGRAM-4
INPUT :

import pandas as pd

import numpy as np

Result={'Student 1': ["90", "80", "70"],

'Student 2':[1, 20, 40],

'Subject': ["Maths", "English", "Social"]}

dFrameresult=pd.DataFrame(Result)

print(dFrameresult)

OUTPUT :

Student 1 Student 2 Subject

0 90 1 Maths

1 80 20 English

2 70 40 Social
PROGRAM-5
INPUT :

import pandas as pd

import numpy as np

dicforest={'State' : ['Assam', 'Delhi', 'Kerela'],

'GArea': [78438, 1483, 38852],

'VDG': [2797, 6.72, 1663]}

dFrameForest=pd.DataFrame(dicforest)

print(dFrameForest)

OUTPUT :

State GArea VDG

0 Assam 78438 2797.00

1 Delhi 1483 6.72

2 Kerela 38852 1663.00

PROGRAM-6
INPUT :

import pandas as pd

import numpy as np

seriesA=pd.Series([1,2,3,4,5], index=['a', 'b', 'c', 'd', 'e'])

seriesB=pd.Series([10,20,-10,-50,100], index = ['z', 'y', 'a', 'c', 'e',])

print(seriesA+seriesB)

OUTPUT :

a -9.0
b NaN

c -47.0

d NaN

e 105.0

y NaN

z NaN

PROGRAM-7
INPUT :

import pandas as pd

import numpy as np

series1=pd.Series(np.arange(10,16,1),

index = ['a', 'b', 'c', 'd', 'e', 'f'])

print(series1)

OUTPUT :

a 10

b 11

c 12

d 13

e 14

f 15
PROGRAM-8
INPUT :

import pandas as pd

import numpy as np

series1=pd.Series(np.arange(10,16,1),

index = ['a', 'b', 'c', 'd', 'e', 'f'])

series1[1:3]=50

print(series1)

OUTPUT :

a 10

b 50

c 50

d 13

e 14

f 15

PROGRAM-9
INPUT :

import pandas as pd

import numpy as np

series1=pd.Series(np.arange(10,16,1),

index = ['a', 'b', 'c', 'd', 'e', 'f'])

series1['c':’e']=500

print(series1)
OUTPUT :

a 10

b 11

c 500

d 500

e 500

f 15

PROGRAM-10
INPUT :

import pandas as pd

import numpy as np

seriestentwenty=pd.Series(np.arange(10,20,1))

print(seriestentwenty)

OUTPUT :

0 10

1 11

2 12

3 13

4 14

5 15

6 16

7 17

8 18

9 19
PROGRAM-11
INPUT :

import pandas as pd

import numpy as np

series2=pd.Series([12,np.nan,10])

print(series2)

OUTPUT :

0 12.0

1 NaN

2 10.0

PROGRAM-12
INPUT :

import pandas as pd

import numpy as np

array1=np.array([10,20,30])

array2=np.array([100,200,300])

array3=np.array([-10,-20,-30,-40])

dFrame4=pd.DataFrame(array1)

print(dFrame4)
OUTPUT :

0 10

1 20

2 30

PROGRAM-13
INPUT :

import pandas as pd

import numpy as np

array1=np.array([10,20,30])

array2=np.array([100,200,300])

array3=np.array([-10,-20,-30,-40])

dFrame5=pd.DataFrame([array1, array3, array2], columns=['A', 'B', 'C', 'D' ])

print(dFrame5)

OUTPUT :

A B C D

0 10 20 30 NaN

1 -10 -20 -30 -40.0

2 100 200 300 NaN


PROGRAM-14
INPUT :

import pandas as pd

dictForest = {'State': ['Assam', 'Delhi', 'Kerala'],

'GArea': [78438, 1483, 38852] ,

'VDF' : [2797, 6.72,1663]}

dFrameForest= pd.DataFrame(dictForest)

print(dFrameForest)

OUTPUT :

State GArea VDF

0 Assam 78438 2797.00

1 Delhi 1483 6.72

2 Kerala 38852 1663.00

You might also like