0

I'm new to python and i have a problem. I'm using pandas to extract data from an excel sheet and create a list from it. This list length varies from 1 to 5 and I would like to extract the values from this list and give them to variables. I have written this piece of code but it doesn't work as I want it to. Is there a way to create as many variables as the length of the list and give them these values? There is the code I wrote:

df = df['Branchements' == df['Activité']]

    print(df)

    entreprises_liste_branchements = df['Prestataire'].tolist()
    entreprises = [numpy.NaN, numpy.NaN, numpy.NaN, numpy.NaN]
    i = 0
    while i < len(entreprises_liste_branchements):
        entreprises = entreprises_liste_branchements[i]
        i += 1
    entreprise1 = entreprises[0]
    entreprise2 = entreprises[1]
    entreprise3 = entreprises[2]
    entreprise4 = entreprises[3]

    PDS_liste = df['point de sortie'].tolist()
    PDS = [numpy.NaN, numpy.NaN, numpy.NaN, numpy.NaN]
    i = 0
    while i < len(PDS_liste):
        PDS = PDS_liste[i]
        i += 1
    PDS1 = PDS[0]
    PDS2 = PDS[1]
    PDS3 = PDS[2]
    PDS4 = PDS[3]
Paul Martin
  • 1
  • 1
  • 2

0 Answers0