0% found this document useful (0 votes)
3 views

DA2_using-matplotlib

The document provides a Python code example demonstrating data manipulation and export using Pandas and NumPy. It includes reading a CSV file, transforming data, and performing array operations. The final output involves saving the manipulated data to a new CSV file and showcasing array arithmetic results.

Uploaded by

thechilledguy08
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

DA2_using-matplotlib

The document provides a Python code example demonstrating data manipulation and export using Pandas and NumPy. It includes reading a CSV file, transforming data, and performing array operations. The final output involves saving the manipulated data to a new CSV file and showcasing array arithmetic results.

Uploaded by

thechilledguy08
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Title :- Manipulating and Exporting the data in Python

using Pandas and NumPy

Name : Himanshu Gholse


Roll.No : 22228
Date : 23/1/24

Code:-

import pandas as pd
import numpy as np

df = pd.read_csv("gap-every-five-years(1).csv")
df
df.head()

sub_1 = df[['country','year','lifeExp','pop']].head(14)
sub_1.dtypes
sub_1

sub_1['lifeExp'] = np.log(sub_1['lifeExp'])
sub_1.to_csv("Sanchit_exp2.csv",index=False)
sub_1.head()

arr_1 = np.array([1,2,3,4,5,6,7,8,9,10,11,12,13,14])
arr_2 = np.random.rand(3,4)

print(arr_1)
print(arr_2)
arr_1_form = arr_1.shape
arr_2_form = arr_2.shape
print("The Representation of the 1 Dimensional Array is:-",arr_1_form)
print("The Representation of the 2 Dimensional Array is:-",arr_2_form)

arr_1_part = arr_1[:5]
arr_2_part = arr_2[1,2]#taking the 2nd Row and 3rd Column[row-1,column-1]
print("The Subset of Array 1 is:-",arr_1_part)
print("The Subset of Array 2 is:-",arr_2_part)

arr_3 = arr_1+5
arr_4 = arr_2*10

print("The Output of Arithmetic Operation on Array 1 is:-",arr_3)


print("The Output of Arithmetic Operation on Array 2 is:-\n",arr_4)

Output:-
#Transfering Data to new CSV file ^

Array Operations:-

You might also like