Questions tagged [genfromtxt]

Numpy function to create arrays from tabular data.

References

287 questions
0
votes
1 answer

use genfromtxt() to load the file and then check the number of missing values in each column using the numpy isnan() function with sum()

I am trying to load this file using genfromtxt and count missing values in each column below is my code: import numpy as np data = np.genfromtxt(datafile, delimiter=",", names=["col1","col2","col3","col4","col5","col6"], dtype=None,…
ashish_goy
  • 31
  • 5
0
votes
0 answers

Numpy genfromtxt() error using converters: Converter function does not skip footer

I am using numpy.genfromtxt() to load time data in string format HH:MM:SS.S, and wishing to modify it according to a converter function (translating string UTC-time into float decimal hours). The code generates errors at the end of the file, where…
Elena
  • 1
  • 2
0
votes
1 answer

trouble deleting specific columns in genfromtxt function

I made a python script which takes pdbqt files as input and returns a txt file. As all the lines doesn't have the same no. of columns its not able to read the files. How can I ignore those lines? sample pdbqt and txt files the code from __future__…
0
votes
0 answers

Using numpy.getfromtxt to convert csv files

I am working on some csv files and would like to convert them to txt. I have developed a for loop in Python in which the comma is set as field separator. However, I don't know how to import the columns contained in inverted commas ". Here is the…
Nicola
  • 1
  • 2
0
votes
1 answer

Numpy data conversion after txt reading with genfromtxt

Let me say I created a file with this three lines A\tB\tC name1\t1\t2 name2\t1.1\t2.2 where \t corresponds to the delimiter. I read it using this numpy function data = np.genfromtxt('test.txt', delimiter='\t', dtype=None, encoding='ascii') Data is…
eljamba
  • 171
  • 1
  • 2
  • 11
0
votes
1 answer

Why is np.genfromtxt returning nan when reading the data files?

I have a list containing the strings of my data files. When I read the data I expect to see a numpy array with 3 columns of floats but instead I just get nan. FILE_NAMES = ['file1.csv', 'file2.csv'] data = np.genfromtxt(FILE_NAMES, delimiter=',',…
Jack
  • 69
  • 6
0
votes
1 answer

numpy genfromtxt IndexError when using comments

I'm trying to import data from a text file into python using genfromtxt(). The code I have currently is lowResOmni = np.genfromtxt('omni low res 7-14 to 7-18.txt', dtype=[('year', int), ('SOY', float) …
root
  • 3
  • 1
0
votes
0 answers

Header Information does not match array. deletechars argument

I am trying to create a numpy array from a geosoft formatted xyz text file. The format uses a '/' to start the header file, then space delimited after. I believe numpy sees the '/' and assigns as column zero. Header info looks like this / Line…
0
votes
1 answer

Genfromtxt value error: got n columns instead 1

I'm using numpy.genfromtxt to import a data column from a csv file as a variable twice (each column corresponding to different variables x and y). I'm getting a Value Error: (got 3 columns instead of 1) even though I;m specifying which column to…
Madmem
  • 7
  • 2
0
votes
0 answers

CSV not opening with delimiter ; but opening with delimiter , using genfromtxt

data = genfromtxt('C:\\Users\\DELL\\Desktop\\ML\\melb_data.csv',dtype = None,delimiter = ',') The csv file opens and I can use it as a numpy array when I specify delimiter to be , data2 =…
0
votes
2 answers

numpy.recfromcsv Transposed Output from CSV File

I have some CSV files that I would be keen to parse with numpy.recfromcsv in one go with a transposed output where basically the light names become the field names. The reason to do it in one go is that I have a wrapper function above…
Kel Solaar
  • 3,660
  • 1
  • 23
  • 29
0
votes
0 answers

problem in data load using nupy genfromtxt, python

My text file (test.out) contains data arrangement are in three rows but the number of columns are different in each row. That is like shown below 2013 531 1155 24.0 L 19.219 76.766 0.2 JOY 3 0.0 0.4LJOY 1 CBN SZ IPg 1155…
0
votes
1 answer

numpy genfromtxt - how to detect bad int input values

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…
user3240688
  • 1,188
  • 3
  • 13
  • 34
0
votes
2 answers

numpy genfromtxt not applying missing_values

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…
C Hecht
  • 932
  • 5
  • 14
0
votes
0 answers

Issue with genfromtxt

I am relatively new to coding and I wanted to try my hand at building code to back-test data, but I am having some issue with extracting a column from my data into a numpy array. Below I have screen shots of how I want it to be formatted and the…