I created a Pandas Series like this:
txt = pd.Series(['1', '2', '3', '4', '5', ""])
print(txt)
Result:
0 1
1 2
2 3
3 4
4 5
5
dtype: object
Find out type of each item and gives me 'str' as result.
type(txt[0])
type(txt[5])
Try to convert each item into 'int' type with .astype() but failed.
txt.astype('int')
ValueError: invalid literal for int() with base 10: ''
Try to convert each item into 'int' type with a self-defined function but got error.
txt.apply(lambda num: int(num))
ValueError: invalid literal for int() with base 10: ''
Someone please advise me how to do data type conversion in this case. My plan is to create 2 pandas Series and perform maths operation on both Series.