Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Read Columns with Numpy

$
0
0
I have a file with lets say with the following X,Y,Z columns

#file.csv
X,Y,Z
1,2,3
4,2,5
15,9,1
#

I am trying to use numpy to read column X and give me the average, standard deviation and other statistics.
I cant get numpy to read them as columns like I want.

import numpy as np
import math
my_data = np.genfromtxt(filename, delimiter=',', dtype=float, names=[x,y,z])
###

if I do something like np.average(my_data) it is averaging every row instead of every column.
How can I make it average X, Y and Z and then print them out in a file?

And X have long numbers like 2747477447437.959843848 and I dont want to round them. These are IDS and should not be changed at all!
Please Help
Thank you

Viewing all articles
Browse latest Browse all 51036

Trending Articles



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