Проверьте, все ли пункты списка являются string integers

У меня есть датафрейм с вопросами и ответами:

,Unnamed: 0,Unnamed: 0.1,Unnamed: 0.1.1,URL,QID,Questions,Answers,QType
0,0,0,1,When do you think your next vacation can start?,"['In next 3 months', 'In next 6 months', 'In next 1 year', 'Only once COVID-19 is under control', 'Only once COVID-19 vaccine is developed']",
1,1,1,2,What are your preferences regarding medical treatment policy (with additional cost)?,"[""Doctor's availability in hotel"", 'Ventilator availability in hotel', 'Tie-ups with nearby hospitals', 'Availability of medical rooms with primary first aid care']",
2,2,2,3,Preferences of complementary breakfast?,"['Buffet breakfast with social distancing', 'Buffet breakfast replaced with Ala-carte with limited options', 'Breakfast to be delivered in room with limited options (chargeable)', 'Packaged breakfast only']",
3,3,3,4,What is your preference for packaged food?,"['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']",
4,4,4,5,Consumer Personality,[],

Я хотел бы получить типы ответов в столбце 'QType'. Т.е. тип ответа: "шкала вкуса" или "множественный выбор". Шкала вкуса - это целые списки чисел, множественный выбор - это все остальные:

def classifier(l):
    l = ast.literal_eval(l)
    if all(type(int(item))==int for item in l):
        l = list(map(int, l))
df.apply(lambda x: classifier(df.Answers), axis = 1)

Но вернись:

Traceback (most recent call last):
  File "<input>", line 5, in <module>
  File "C:\Users\antoi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pandas\core\frame.py", line 6878, in apply
    return op.get_result()
  File "C:\Users\antoi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pandas\core\apply.py", line 186, in get_result
    return self.apply_standard()
  File "C:\Users\antoi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pandas\core\apply.py", line 296, in apply_standard
    values, self.f, axis=self.axis, dummy=dummy, labels=labels
  File "pandas\_libs\reduction.pyx", line 620, in pandas._libs.reduction.compute_reduction
  File "pandas\_libs\reduction.pyx", line 128, in pandas._libs.reduction.Reducer.get_result
  File "<input>", line 5, in <lambda>
  File "<input>", line 2, in classifier
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2032.0_x64__qbz5n2kfra8p0\lib\ast.py", line 91, in literal_eval
    return _convert(node_or_string)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2032.0_x64__qbz5n2kfra8p0\lib\ast.py", line 90, in _convert
    return _convert_signed_num(node)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2032.0_x64__qbz5n2kfra8p0\lib\ast.py", line 63, in _convert_signed_num
    return _convert_num(node)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2032.0_x64__qbz5n2kfra8p0\lib\ast.py", line 55, in _convert_num
    raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: 0       ['In next 3 months', 'In next 6 months', 'In n...
1       ["Doctor's availability in hotel", 'Ventilator...
2       ['Buffet breakfast with social distancing', 'B...
3       ['1', '2', '3', '4', '5', '6', '7', '8', '9', ...
4                                                    ['']

Ответы (0 шт):