Pandas Series Flashcards
Where
my_list = [10,20,30]
:
pd.Series(data=my_list)
0 10
1 20
2 30
dtype: int64
Where
labels = [‘a’,’b’,’c’]
my_list = [10,20,30]
:
pd.Series(data=my_list,index=labels)
a 10
b 20
c 30
dtype: int64
Simplify pd.Series(data=my_list,index=labels)
pd.Series(my_list,labels)
Where
arr = np.array([10,20,30])
:
pd.Series(arr)
0 10
1 20
2 30
dtype: int64
Where
arr = np.array([10,20,30])
labels = [‘a’,’b’,’c’]
:
pd.Series(arr,labels)
a 10
b 20
c 30
dtype: int64
Where
d = {‘a’:10,’b’:20,’c’:30}
:
pd.Series(d)
a 10
b 20
c 30
dtype: int64
Where
labels = [‘a’,’b’,’c’]
:
pd.Series(data=labels)
0 a
1 b
2 c
dtype: object
pd.Series([sum,print,len])
0 <built-in>
1 <built-in>
2 <built-in>
dtype: object</built-in></built-in></built-in>
Where
ser1 = pd.Series([1,2,3,4],index = [‘USA’, ‘Germany’,’USSR’, ‘Japan’])
:
ser1
USA 1
Germany 2
USSR 3
Japan 4
dtype: int64
Where
ser2 = pd.Series([1,2,5,4],index = [‘USA’, ‘Germany’,’Italy’, ‘Japan’])
:
ser2
USA 1
Germany 2
Italy 5
Japan 4
dtype: int64
Where
ser1 = pd.Series([1,2,3,4],index = [‘USA’, ‘Germany’,’USSR’, ‘Japan’])
:
ser1[‘USA’]
1
Where
ser1 = pd.Series([1,2,3,4],index = [‘USA’, ‘Germany’,’USSR’, ‘Japan’])
ser1[‘USA’]Where ser2 = pd.Series([1,2,5,4],index = [‘USA’, ‘Germany’,’Italy’, ‘Japan’])
:
ser1 + ser2
Germany 4.0
Italy NaN
Japan 8.0
USA 2.0
USSR NaN
dtype: float64