for function in Python3 - how to print all elements of a series

Asked

Viewed 62 times

-1

i = 0
for item in test['text'][i]:
    print(test['text'][i])
    print(i)
    i+=1

in my dataset "test" I have 3262 items( is a series ) however when I do "for" it "printa" only 32 items

2 answers

0

What you’re doing with this code is actually iterating the elements within the variable test['text'][i].

Maybe you’re actually trying to iterate on the element test['text'].

Execute the following code:

for item in test['text']:
    print(item)

print("Quantidade de itens no dicionário test, usando a chave text: ", len(test['text']) )

-1


welcome to the community. has tried to do the following?

for i in range(1,32): # percorre um laço de 1 até 32 
     print('Numero: '+str(i)+' Dicionario: '+str(test['text'][i])) # mostra o numero percorrido e mostra o dicionario + o texto equivalente ao numero

Browser other questions tagged

You are not signed in. Login or sign up in order to post.