Billones SebastianLuise Week3Exercise00Series
Billones SebastianLuise Week3Exercise00Series
Objectives:
● Understand the programming fundamentals and the Python language.
● Write Python programs that utilize variables, data types, and operators.
Instructions:
1. To complete this exercise, please follow the sample commands in Python provided to you.
Once you have completed the assignment, please submit the IPython file and this
document to me. You have one week to complete the exercise from the assigned date.
Please let me know if you have any questions or concerns regarding the assignment.
2. When submitting your completed assignment, please name the IPython file as follows:
"surname_firstname_MP1Exercise". Replace "surname" with your last name, "firstname" with
your first name, and "MP2Exercise" with the name of the machine problem.
For example, if your name is John Smith and the machine problem is "PythonExercise2", the
file name should be "smith_john_PythonExercise1.ipynb".
Please adhere to this naming convention when submitting your file. This will ensure I can
quickly identify your submission and provide appropriate feedback.
Series: The first main data type we will learn about for pandas is the Series data
type. Let's import Pandas and explore the Series object.
A Series is very similar to a NumPy array (in fact it is built on top of the NumPy array
object). What differentiates the NumPy array from a Series, is that a Series can
have axis labels, meaning it can be indexed by a label, instead of just a number
location. It also doesn't need to hold numeric data, it can hold any arbitrary
Python Object.
In [6] myser
Out[6] 0 1776
1 1867
2 1821
dtype: int64
In [7] pd.Series(data=mydata,index=myindex)
In [9] ran_data
In [12] ages
Out[12] Andrew 61
Bobo 95
Claire 92
David 78
dtype: int32
From a Dictionary
In [14] ages
In [15] pd.Series(ages)
Out[15] Sammy 5
Frank 10
Spike 7
dtype: int64
Named Index
In [16] # Imaginary Sales Data for 1st and 2nd Quarters for Global Company
q1 = {'Japan': 80, 'China': 450, 'India': 200, 'USA': 250}
In [18] sales_Q1
Out[18] Japan 80
China 450
India 200
USA 250
dtype: int64
Out[19] 80
Out[20]
Operations
Between Series
In [25] # You can fill these with any value you want
sales_Q1.add(sales_Q2,fill_value=0)