genfromtxt

numpy genfromtxt not applying missing_values

ぐ巨炮叔叔 提交于 2021-02-11 12:58:24
问题 I am currently struggling with a really simple problem, but cannot seem to solve it. You can reproduce the issue with the following file and code: test.csv 2020081217,28.6 2020081218,24.7 2020081219,-999.0 2020081220,-999.0 2020081221,-999.0 code data = np.genfromtxt("C:/Users/col/Downloads/test.csv", delimiter=',', missing_values=["-999", "-999.0", -999, -999.0]) print(data) output [[ 2.02008122e+09 2.86000000e+01] [ 2.02008122e+09 2.47000000e+01] [ 2.02008122e+09 -9.99000000e+02] [ 2

numpy genfromtxt not applying missing_values

倾然丶 夕夏残阳落幕 提交于 2021-02-11 12:57:53
问题 I am currently struggling with a really simple problem, but cannot seem to solve it. You can reproduce the issue with the following file and code: test.csv 2020081217,28.6 2020081218,24.7 2020081219,-999.0 2020081220,-999.0 2020081221,-999.0 code data = np.genfromtxt("C:/Users/col/Downloads/test.csv", delimiter=',', missing_values=["-999", "-999.0", -999, -999.0]) print(data) output [[ 2.02008122e+09 2.86000000e+01] [ 2.02008122e+09 2.47000000e+01] [ 2.02008122e+09 -9.99000000e+02] [ 2

numpy genfromtxt - how to detect bad int input values

跟風遠走 提交于 2021-01-29 06:49:30
问题 Here is a trivial example of a bad int value to numpy.genfromtxt . For some reason, I can't detect this bad value, as it's showing up as a valid int of -1. >>> bad = '''a,b 0,BAD 1,2 3,4'''.splitlines() My input here has 2 columns of ints, named a and b. b has a bad value, where we have a string "BAD" instead of an integer. However, when I call genfromtxt , I cannot detect this bad value. >>> out = np.genfromtxt(bad, delimiter=',', dtype=(numpy.dtype('int64'), numpy.dtype('int64')), names

Read in all csv files from a directory using Python

a 夏天 提交于 2020-04-29 06:05:29
问题 I hope this is not trivial but I am wondering the following: If I have a specific folder with n csv files, how could I iteratively read all of them, one at a time, and perform some calculations on their values? For a single file, for example, I do something like this and perform some calculations on the x array: import csv import os directoryPath=raw_input('Directory path for native csv file: ') csvfile = numpy.genfromtxt(directoryPath, delimiter=",") x=csvfile[:,2] #Creates the array that

np.loadtxt vs np.genfromtxt

丶灬走出姿态 提交于 2020-01-30 11:37:46
问题 when I use the following np.loadtxt code to load the data of the format: 2017-07-26,153.3500,153.9300,153.0600,153.5000,153.5000,12778195.00 the data gets loaded just fine, loadtxt code-> a, b, c, d, e, f, g = np.loadtxt("goog.csv", dtype={'names': ("b'Date", 'Open', 'High', 'Low', 'Close', 'Adjusted_close', 'Volume'), 'formats': ('U10', np.float, np.float, np.float, np.float, np.float, np.float)}, delimiter=',', skiprows=1, unpack=True) print(a) Output-> ['2017-07-26' '2017-07-25' '2017-07

np.loadtxt vs np.genfromtxt

纵然是瞬间 提交于 2020-01-30 11:36:10
问题 when I use the following np.loadtxt code to load the data of the format: 2017-07-26,153.3500,153.9300,153.0600,153.5000,153.5000,12778195.00 the data gets loaded just fine, loadtxt code-> a, b, c, d, e, f, g = np.loadtxt("goog.csv", dtype={'names': ("b'Date", 'Open', 'High', 'Low', 'Close', 'Adjusted_close', 'Volume'), 'formats': ('U10', np.float, np.float, np.float, np.float, np.float, np.float)}, delimiter=',', skiprows=1, unpack=True) print(a) Output-> ['2017-07-26' '2017-07-25' '2017-07

Read ints from .txt file into numpy array

馋奶兔 提交于 2020-01-30 02:42:34
问题 I'm tring to read 4 ints from simple .txt array as described in this question genfromtxt : read ints from space separated .txt file but I want it as 2D numpy array. def read_data(): data = np.genfromtxt('Skin_NonSkin.txt', dtype=(int, int, int, int)) print type(data) print data.shape print data[0] print type(data[0]) print data[0].shape print data[0][1] return data it gives me <type 'numpy.ndarray'> (245057L,) (74, 85, 123, 1) <type 'numpy.void'> () 85 So how to properly read the data or

python genfromtxt problems

天涯浪子 提交于 2020-01-24 13:05:13
问题 I am new to Python...here is my problem. For an optimizing subroutine I am testing in Python, I need to parse a csv file with numbers. The format of the csv file is thus: Support load summary for anchor at node 5, Load combination,FX (N),FY (N),FZ (N),MX (Nm),MY (Nm),MZ (Nm),, Sustained,-3,-2679,120,2012,164,69,, Operating1,1472,2710,-672,-4520,8743,-2047,, Maximum,1472,2710,120,2012,8743,69,, Minimum,-3,-2679,-672,-4520,164,-2047,, Support load summary for anchor at node 40, Load combination

Numpy's genfromtxt returns different structured data depending on dtype parameters

狂风中的少年 提交于 2020-01-16 19:11:15
问题 I have the following: from numpy import genfromtxt seg_data1 = genfromtxt('./datasets/segmentation.all', delimiter=',', dtype="|S5") seg_data2 = genfromtxt('./datasets/segmentation.all', delimiter=',', dtype=["|S5"] + ["float" for n in range(19)]) print seg_data1 print seg_data2 print seg_data1[:,0:1] print seg_data2[:,0:1] it turns out that seg_data1 and seg_data2 are not the same kind of structure. Here's what printed: [['BRICK' '140.0' '125.0' ..., '7.777' '0.545' '-1.12'] ['BRICK' '188.0'

Numpy's genfromtxt returns different structured data depending on dtype parameters

北慕城南 提交于 2020-01-16 19:10:27
问题 I have the following: from numpy import genfromtxt seg_data1 = genfromtxt('./datasets/segmentation.all', delimiter=',', dtype="|S5") seg_data2 = genfromtxt('./datasets/segmentation.all', delimiter=',', dtype=["|S5"] + ["float" for n in range(19)]) print seg_data1 print seg_data2 print seg_data1[:,0:1] print seg_data2[:,0:1] it turns out that seg_data1 and seg_data2 are not the same kind of structure. Here's what printed: [['BRICK' '140.0' '125.0' ..., '7.777' '0.545' '-1.12'] ['BRICK' '188.0'