0

During a pandas DF loop, i'm trying to split the result of variable in two, but i got an error:

My code:

 ...  
 for e in zip(list(df[each_column]), list(df['epoch'])):
      print(metric,'=',e)
      epoch_time = e.split(',')[1]
      value = e.split(',')[0]
 ...

The print of variable e:

on 0: metric = ('1121', 1656428160)
on 0: metric = ('1101', 1656428220)
on 0: metric = ('1015', 1656428280)

I would like to get

on 0: metric = 1121 1656428160
on 0: metric = 1101 1656428220
on 0: metric = 1015 1656428280

--> error when i tried to split e:

AttributeError: 'tuple' object has no attribute 'split'

How can i get each value separately?

Many thanks for help

0

1 Answer 1

0

Your variable e is in tuple which can't be split. However you can convert it to a list and then print it like this:

print(*list(e))
Sign up to request clarification or add additional context in comments.

1 Comment

@Indi59 Please approve the answer if it worked

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.