Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7691777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:42:03+00:00 2026-05-31T20:42:03+00:00

I have three lists that I want to convert into one list. When I

  • 0

I have three lists that I want to convert into one list. When I try the following a get this error

 A = numpy.array(X,Y,Z,dtype=float)
 ValueError: only 2 non-keyword arguments accepted

I did not see anything here that says you can only give it two arguments

http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html

Here is the code

import numpy
from numpy import *

X = []
Y = []
Z = []

f = open(r'C:\My.txt')
f.readline()
for line in f:
 if line != '':
     line = line.strip()
     columns = line.split()
     x = columns[2]
     y = columns[3]
     z = columns[4]
     X.append(x)
     Y.append(y)                #appends data in list
     Z.append(z)



A = numpy.array(X,Y,Z,dtype=float)
A.shape(3,3)
print(A)

Thanks in advanceh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:42:04+00:00Added an answer on May 31, 2026 at 8:42 pm

    Try passing your three lists as a tuple:

    A = numpy.array((X, Y, Z), dtype=float)
    

    In the numpy.array documentation the signature for numpy.array is

    numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0, maskna=None, ownmaskna=False)

    i.e. the single argument object is what gets turned into an ndarray, every other argument must be a keyword argument (hence the error message which you were getting) which can be used to customise the creation of the array.

    Edit In respone to Surfcast23’s comment, in the IDE I tried the following:

    >>> import numpy
    
    >>> x = [0, 0, 0, 0]
    >>> y = [3, 4, 4, 3]
    >>> z = [3, 4, 3, 4]
    
    >>> A = numpy.array((x, y, z), dtype=float)
    >>> A
    array([[ 0., 0., 0., 0.],
           [ 3., 4., 4., 3.],
           [ 3., 4., 3., 4.]])
    >>> A.shape
    (3L, 4L)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tab delimeted file that I want to convert into a mysql
I have a list of objects that I want to transform into another list
I have string on the format $0Option one$1$Option two$2$Option three (etc) that I want
I have a binary tree in unordered list that looks like this: <ul> <li>1
On this page there is a list of footer links that have a little
So I currently have three unordered lists in my header. This is a single-page
I have a string $regexp_as_string Now I want to convert it into an regex
I want to get a list of result sets and columns that i can
I have many pages where I get data entry forms such that one HTML
I have a site where there will be a list of offers that the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.