Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

How to insert output of a python for loop into an excel column?

$
0
0

I'm trying to use a for loop to populate data in a destination column in an excel spreadsheet. The destination column gets made but then the information from the for loop doesn't print into the excel file.

import pandas as pd
aasb_scores = pd.read_excel ('/Users/nnamdiokoli/Library/Containers/com.microsoft.Excel/Data/Desktop/AASB Scoring PivotTable Example.xlsx', 
                             index=False) 

aasb_scores['Average'] = (aasb_scores['Q1'] + 
           aasb_scores['Q2']+ aasb_scores['Q3'] + 
           aasb_scores['Q4'] + aasb_scores['Q5'])/5.00
aasb_scores.head(10)

def finalround():
    for i in aasb_scores['Average']:
        if i >= 3:
            print('Final Round')
        else:
            print('cut')

aasb_scores['Moving on?'] = finalround()

aasb_scores.to_excel('/Users/nnamdiokoli/Library/Containers/com.microsoft.Excel/Data/Desktop/AASB Scoring PivotTable Example.xlsx',
                     index=False)

Viewing all articles
Browse latest Browse all 88835

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>