Averaging a list in Python, "Type Error: Cannot perform reduce with flexible type"
Question: The code below is supposed to do as follows:

  1. Fill an empty list with a specific column of numbers from a csv file. 

  2. The average of the list values is then calculated and the resulting value is plotted. 

Problems: I keep getting the error "TypeError: cannot perform reduce with
flexible type". All I do know is that it has to do something with condensing
down a list. But I'm not sure beyond that. Any help is appreciated.

    
    
    import csv 
    import matplotlib.pyplot as plt 
    import numpy as np 
    
    channelData = []
    
    channelSel = int(input("Select a channel to view "))
    
    with open('PrivateData.csv', newline='') as f: 
        reader = csv.reader(f)
        for row in reader:
            channelData.append(row[channelSel])
    
    averagemV = np.mean(channelData)
    
    plt.plot(averagemV) 
    plt.ylabel("Average mV")
    plt.xlabel("Channel " + str(channelSel))
    plt.show()
    


Answer: 
    with open('PrivateData.csv', newline='') as f: 
        reader = csv.reader(f)
        for row in reader:
            channelData.append(row[channelSel])
    

I suspect that this is adding strings that look like floats to `channelData`,
rather than actual floats. Try explicitly converting.

    
    
    with open('PrivateData.csv', newline='') as f: 
        reader = csv.reader(f)
        for row in reader:
            channelData.append(float(row[channelSel]))
    

