gpt-3.5-turbo-0613· OpenAI WildChat-4.8M (AI2)
I have a column column = [[481448145555, 601148145555, 481460114444, 601160114444,…
- User
I have a column column = [[481448145555, 601148145555, 481460114444, 601160114444, 541160114444, 531154115555, 481453113333, 531148144444, 601153113333, 601060100000],[601060100000,481448145555, 601148145555, 481460114444, 601160114444, 541160114444, 531154115555, 481453113333, 531148144444, 601153113333]]
I need to get new columns where each values is splitted by four digits. And the new list conatins only 10 elements. So I need
column = [[4814, 4814, 5555, 6011, 4814, 5555, 4814, 6011, 4444, 6011],[6010, 6010, 0000, 4814, 4814, 5555, 6011, 4814, 5555, 4814]]
Provide a Python script
- Assistant
Here's a Python script that splits each value in the column list into four digits and creates a new list with only 10 elements:
column = [[481448145555, 601148145555, 481460114444, 601160114444, 541160114444, 531154115555, 481453113333, 531148144444, 601153113333, 601060100000], [601060100000, 481448145555, 601148145555, 481460114444, 601160114444, 541160114444, 531154115555, 481453113333, 531148144444, 601153113333]] new_column = [] for lst in column: new_lst = [] for value in lst: new_value = [int(str(value)[i:i+4]) for i in range(0, len(str(value)), 4)] new_lst.extend(new_value) new_column.append(new_lst[:10]) print(new_column)Output:
[[4814, 4814, 5555, 6011, 4814, 5555, 4814, 6011, 4444, 6011], [6010, 6010, 0, 4814, 4814, 5555, 6011, 4814, 5555, 4814]]