Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Lab 2: Read and Working with Data using Pandas This lab will introduce you to using open source software written in Python and authored by other individuals. Popular open source software projects in...

1 answer below »
Lab 2: Read and Working with Data using Pandas
 This lab will introduce you to using open source software written in Python and authored by other individuals. Popular open source software projects in Python that are relevant to this program include:
Lab 2.a: Introduction to Pandas and Numpy Data Structures
Review the following documentation from Pandas about data structures: https:
pandas.pydata.org/pandas-docs/stable/getting_started/dsintro.html (Links to an external site.). This will introduce you to the Series and DataFrame. There is no need to read about Panels unless you would like to). You will see references to numpy a
ays which you can review separately in this tutorial (Links to an external site.) from the Data Science Handbook.
Deliverables:
· Code for creating and printing a 2 by 3 numpy a
ay of random numbers
· Code for creating a Series of 5 random numbers with indexes from 0 to 4
· Code for creating a DataFrame containing two Series of 5 random numbers and indexed with the letters “a” through “e”
Lab 2.b: Reading CSV files into DataFrames
DataFrames are useful for performing calculations so we typically will read a CSV or other data file into a DataFrame before doing more calculations. Review the following documentation from Pandas for reading a CSV file into a DataFrame. Explore the methods available for DataFrames as well (e.g. df.head(10) ).
When you read in data, it will be messy. Research how to clean the data in the DataFrame on your own:
· User Guide for Pandas IO Tools (Links to an external site.)
· Getting Data in and Out (Links to an external site.)
· Pandas.read_csv Documentation (Links to an external site.)
· Pandas.to_csv Documentation (Links to an external site.)
Deliverables:
· Code for reading the CSV file into a Pandas DataFrame
· Code for cleaning the data (e.g. convert strings to integers and floats)
· Code for writing a cleaner DataFrame to a new CSV file
Answered Same Day Jan 30, 2021

Solution

Sudipta answered on Jan 31 2021
148 Votes
2.A.i) Create a 2 by 3 numpy a
ay of random numbers
import numpy as np
a=np.random.rand(2,3)
print(a)
2.A.ii) Create a series of 5 random numbers with index from 0-4
import numpy as np
import pandas as pd
d=np.random.rand(5)
s1=pd.Series(d,index=[0,1,2,3,4])
print(s1)
2.A.iii) Creating a dataframe containing 2 series of 5 random numbers with index a-e
import pandas as pd
import numpy as np
d=np.random.rand(5)
e=np.random.rand(5)
s1 =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here