My DataFrame row line = fd.iloc[0] is:
id 31458598
total_matched 104671.25
market Under 3.5 Goals FT
one 0
two 0
three 0
four 0
five 0
Name: 0, dtype: object
I have join this values with comma, like this:
f"{line['id']},{line['total_matched']},{line['market']},{line['one']},{line['two']},{line['three']},{line['four']},{line['five']}\n"
But this method is archaic, so I tried to use join:
','.join(line) + '\n'
TypeError: sequence item 0: expected str instance, numpy.int64 found
line.join(',') + '\n'
AttributeError: 'Series' object has no attribute 'join'
What is the correct way to join these values with a comma?
>Solution :
You can use str.cat after ensuring you have strings:
line.astype(str).str.cat(sep=',')
output: '31458598,104671.25,Under 3.5 Goals FT,0,0,0,0,0,0'