CS计算机代考程序代写 In [1]:

In [1]:
import pandas as pd
import numpy as np

myseries = pd.Series([4, 7, -5, 3])
myseries
Out[1]:
0 4
1 7
2 -5
3 3
dtype: int64
In [3]:
myseries2 = pd.Series([4, 7, -5, 3], index=[‘x’, ‘b’, ‘a’, ‘c’])
myseries2
Out[3]:
x 4
b 7
a -5
c 3
dtype: int64
In [4]:
myseries.values
Out[4]:
array([ 4, 7, -5, 3], dtype=int64)
In [6]:
myseries2.index
Out[6]:
Index([‘x’, ‘b’, ‘a’, ‘c’], dtype=’object’)
In [9]:
myseries2[‘b’]
Out[9]:
7
In [10]:
myseries2[‘a’]

frame= { ‘theseries’: myseries, ‘ultimate series’: myseries2 }

dd= pd.DataFrame(frame)
dd
Out[10]:

theseries
ultimate series
0
4.0
NaN
1
7.0
NaN
2
-5.0
NaN
3
3.0
NaN
a
NaN
-5.0
b
NaN
7.0
c
NaN
3.0
x
NaN
4.0
In [12]:
raw_data = {‘first_name’: [‘Jason’, ‘Molly’, ‘Tina’, ‘Jake’, ‘Amy’],
‘last_name’: [‘Miller’, ‘Jacobson’, “.”, ‘Milner’, ‘Cooze’],
‘age’: [42, 52, 36, 24, 73],
‘preTestScore’: [4, 24, 31, “.”, “.”],
‘postTestScore’: [“25,000”, “94,000”, 57, 62, 70]}
df = pd.DataFrame(raw_data, columns = [‘first_name’, ‘last_name’, ‘age’, ‘preTestScore’, ‘postTestScore’])
df
Out[12]:

first_name
last_name
age
preTestScore
postTestScore
0
Jason
Miller
42
4
25,000
1
Molly
Jacobson
52
24
94,000
2
Tina
.
36
31
57
3
Jake
Milner
24
.
62
4
Amy
Cooze
73
.
70
In [13]:
df.to_csv(‘exampledf.csv’)
In [ ]: