Map function: Type error on iter #999
COLLABORATOR
Hi, thanks for reporting.

It would be really helpful if you could provide the actual code of the `text_numbers_to_int` function so we can reproduce the error.
2021-11-28T13:38:18Z
https://github.com/huggingface/datasets/issues/3329#issuecomment-981087221
https://api.github.com/repos/huggingface/datasets/issues/3329
IC_kwDODunzps46ejP1
https://api.github.com/repos/huggingface/datasets/issues/comments/981087221/reactions
2021-11-28T13:38:18Z
https://api.github.com/repos/huggingface/datasets/issues/comments/981087221
https://avatars.githubusercontent.com/u/47462742?v=4
https://api.github.com/users/mariosasko/events{/privacy}
https://api.github.com/users/mariosasko/followers
https://api.github.com/users/mariosasko/following{/other_user}
https://api.github.com/users/mariosasko/gists{/gist_id}
https://github.com/mariosasko
mariosasko
MDQ6VXNlcjQ3NDYyNzQy
https://api.github.com/users/mariosasko/orgs
https://api.github.com/users/mariosasko/received_events
https://api.github.com/users/mariosasko/repos
https://api.github.com/users/mariosasko/starred{/owner}{/repo}
https://api.github.com/users/mariosasko/subscriptions
User
https://api.github.com/users/mariosasko
public
NONE
```
def text_numbers_to_int(text, column=""):
    """
    Convert text numbers to int.

    :param text: text numbers
    :return: int
    """
    try:
        numbers = find_numbers(text)
        if not numbers:
            return text
        result = ""
        i, j = 0, 0
        while i < len(text):
            if j < len(numbers) and i == numbers[j][1]:
                n = int(numbers[j][0]) if numbers[j][0] % 1 == 0 else float(numbers[j][0])
                result += str(n)
                i = numbers[j][2] #end
                j += 1
            else:
                result += text[i]
                i += 1
        if column:
            return{column: result}
        else:
            return {column: result}
    except Exception as e:
        print(e)
        return {column: result}
```
2021-11-29T01:01:09Z
https://github.com/huggingface/datasets/issues/3329#issuecomment-981203210
https://api.github.com/repos/huggingface/datasets/issues/3329
IC_kwDODunzps46e_kK
https://api.github.com/repos/huggingface/datasets/issues/comments/981203210/reactions
2021-11-29T01:01:09Z
https://api.github.com/repos/huggingface/datasets/issues/comments/981203210
https://avatars.githubusercontent.com/u/52659318?v=4
https://api.github.com/users/josephkready666/events{/privacy}
https://api.github.com/users/josephkready666/followers
https://api.github.com/users/josephkready666/following{/other_user}
https://api.github.com/users/josephkready666/gists{/gist_id}
https://github.com/josephkready666
josephkready666
MDQ6VXNlcjUyNjU5MzE4
https://api.github.com/users/josephkready666/orgs
https://api.github.com/users/josephkready666/received_events
https://api.github.com/users/josephkready666/repos
https://api.github.com/users/josephkready666/starred{/owner}{/repo}
https://api.github.com/users/josephkready666/subscriptions
User
https://api.github.com/users/josephkready666
public
MEMBER
Maybe this is because of the `return text` line ? I think it should return a dictionary rather than a string
2021-11-29T11:21:46Z
https://github.com/huggingface/datasets/issues/3329#issuecomment-981542638
https://api.github.com/repos/huggingface/datasets/issues/3329
IC_kwDODunzps46gSbu
https://api.github.com/repos/huggingface/datasets/issues/comments/981542638/reactions
2021-11-29T11:21:46Z
https://api.github.com/repos/huggingface/datasets/issues/comments/981542638
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
NONE
Yes that was it, good catch! Thanks
2021-11-29T20:40:15Z
https://github.com/huggingface/datasets/issues/3329#issuecomment-982002711
https://api.github.com/repos/huggingface/datasets/issues/3329
IC_kwDODunzps46iCwX
https://api.github.com/repos/huggingface/datasets/issues/comments/982002711/reactions
2021-11-29T20:40:15Z
https://api.github.com/repos/huggingface/datasets/issues/comments/982002711
https://avatars.githubusercontent.com/u/52659318?v=4
https://api.github.com/users/josephkready666/events{/privacy}
https://api.github.com/users/josephkready666/followers
https://api.github.com/users/josephkready666/following{/other_user}
https://api.github.com/users/josephkready666/gists{/gist_id}
https://github.com/josephkready666
josephkready666
MDQ6VXNlcjUyNjU5MzE4
https://api.github.com/users/josephkready666/orgs
https://api.github.com/users/josephkready666/received_events
https://api.github.com/users/josephkready666/repos
https://api.github.com/users/josephkready666/starred{/owner}{/repo}
https://api.github.com/users/josephkready666/subscriptions
User
https://api.github.com/users/josephkready666
public
## Describe the bug
Using the map function, it throws a type error on iter #999

Here is the code I am calling:
```
dataset = datasets.load_dataset('squad')
dataset['validation'].map(text_numbers_to_int, input_columns=['context'], fn_kwargs={'column': 'context'})
``` 
text_numbers_to_int returns the input text with numbers replaced in the format {'context': text}

It happens at 
`
File "C:\Users\lonek\anaconda3\envs\ai\Lib\site-packages\datasets\arrow_writer.py", line 289, in <listcomp>
    [row[0][col] for row in self.current_examples], type=col_type, try_type=col_try_type, col=col
`

The issue is that the list comprehension expects self.current_examples to be type tuple(dict, str), but for some reason 26 out of 1000 of the sefl.current_examples are type tuple(str, str)

Here is an example of what self.current_examples should be
({'context': 'Super Bowl 50 was an...merals 50.'}, '')

Here is an example of what self.current_examples are when it throws the error:
('The Panthers used th... Marriott.', '')
