Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to split a tolist result in two groups (new lists)?

I have a problem, I try many things and I can’t manage to do this.
It’s a code that check if the delivery numbers are on our sales report.

Here it’s the code:

dfn = dfn.astype('str')
diff = dfn[~dfn['Numero de Envio'].isin(dfn['Unnamed: 13'])].dropna()[['Numero de Envio','Fecha']].values.tolist() 
print(f"\n Hay ventas que podrían no ser nuestras: \U0001F611 - Revisar :" '\n')
diff 

The result is:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

[['piedras blancas', '2022-12-01'],
 ['41845010982', '2022-12-01'],
 ['carrasco norte', '2022-12-05'],
 ['41855309788', '2022-12-05'],
 ['villa española ', '2022-12-07'],
 ['aires puros', '2022-12-08'],
 ['monica villa borges', '2022-12-08'],
 ['nicolas diego ', '2022-12-08'],
 ['enrique permuy', '2022-12-08'],
 ['natalia blanco', '2022-12-08'],
 ['laurita', '2022-12-09'],
 ['hugo carrion', '2022-12-10'],
 ['4187289809', '2022-12-12'],
 ['mariana', '2022-12-12'],
 ['amelia vignolo', '2022-12-14'],
 ['leonardo saucedo', '2022-12-14'],
 ['14891993727', '2022-12-17'],
 ['maria noel dottone', '2022-12-19'],
 ['41899599250', '2022-12-19'],
 ['41898783286', '2022-12-19'],
 ['corpo pilates ltd', '2022-12-19'],
 ['serrana bentancour', '2022-12-20'],
 ['fabiana lima', '2022-12-21'],
 ['41916589225', '2022-12-26'],
 ['41917845465', '2022-12-26'],
 ['41916895866', '2022-12-26'],
 ['41917386564', '2022-12-26'],
 ['41917285884', '2022-12-26'],
 ['41900719115', '2022-12-27'],
 ['mauro gonzalez', '2022-12-27']]

I want to split in two groups: The ones that start with numbers and the other the names, my expected result is:

['41845010982', '2022-12-01']          
['41899599250', '2022-12-19'],
['41898783286', '2022-12-19']
['41916589225', '2022-12-26'],
['41917845465', '2022-12-26'],
['41916895866', '2022-12-26'],
['41917386564', '2022-12-26'],
['41917285884', '2022-12-26'],
['41900719115', '2022-12-27'],


['villa española ', '2022-12-07'],
['aires puros', '2022-12-08'],
['monica villa borges', '2022-12-08'],
['nicolas diego ', '2022-12-08'],
['enrique permuy', '2022-12-08'],
['natalia blanco', '2022-12-08'],
['laurita', '2022-12-09'],
['hugo carrion', '2022-12-10'],

>Solution :

You can do this with two for loops:

# prints all numbers
for i in diff:
    if i[0].isnumeric():
        print(i)

print('') # new line

# prints all non-numbers
for i in diff:
    if not i[0].isnumeric():
        print(i)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading