pandas-1
pandas-1
[2]: 0 10
1 20
2 30
3 40
4 50
dtype: int64
[3]: type(sr1)
[3]: pandas.core.series.Series
[4]: sr1[3]
[4]: 40
[ ]: # pandas.core.series.Series
[6]: 40
[5]: a 10.0
b 20.0
c 30.0
1
d 40.0
e 50.0
dtype: float64
[7]: sr2['d']
[7]: 40.0
[ ]:
DataFrame
[10]:
[10]: 0 1
1 2
2 3
3 4
dtype: int64
[12]: df1.dtypes
# int --> int64/32
# float --> float64/float32
# string --> objects
2
dtype: object
[ ]:
Merge
[13]: df1 = pd.DataFrame({'id': [1,2,3,4,5], 'ml_marks': [94,95,98,92,90]})
df1
[13]: id ml_marks
0 1 94
1 2 95
2 3 98
3 4 92
4 5 90
[14]: id stat_marks
0 3 98
1 4 84
2 5 88
3 6 96
4 7 94
3
2 5 90.0 88
3 6 NaN 96
4 7 NaN 94
[ ]: # df1.merge(df2,how = 'cross')
# df1.merge(df1, on = 'id')
[ ]:
Concate
[ ]: # combine two data frame at row level ( increaase no.of rows by using second␣
↪data frame)
[20]: df2
[20]: id ml_marks
0 6 94
1 7 95
2 8 98
3 9 92
4 10 90
[21]: pd.concat([df1,df2])
[21]: id ml_marks
0 1 94
1 2 95
2 3 98
3 4 92
4 5 90
0 6 94
1 7 95
4
2 8 98
3 9 92
4 10 90
[ ]: # Join --> it performs the same operation of combining data frames like Merge␣
↪but on index values
[24]: 'C:\\Users\\admin\\2802'
[ ]: # pd.read_excel('filename.xlsx')
5
4 NaN 8.0 NaN 140 3449 10.5 70
origin name
0 1 chevrolet chevelle malibu
1 1 buick skylark 320
2 1 plymouth satellite
3 1 amc rebel sst
4 1 ford torino