0

I have a numpy array that looks like below:

x = ['11BIT' '4FUNMEDIA' 'ABCDATA' 'ABPL' 'ACAUTOGAZ' 'ADIUVO']

The output should be like this:

x = ['11BIT', '4FUNMEDIA', 'ABCDATA', 'ABPL', 'ACAUTOGAZ', 'ADIUVO']

I tried to use x.tolist() but it didn't help. Basically I need a coma between values. Anyone could help ?

Thanks All

4
  • 1
    What does that even mean, 'I need a comma between values'? Commented Dec 4, 2018 at 19:41
  • 1
    Python uses a comma to separate values within any list-like object. The comma doesn't really exist in the array. I don't really see how you could have gotten your first result. Commented Dec 4, 2018 at 19:44
  • Perhaps it was unclear. I have a array that has 6 elements and I need to convert into list with 6 elements Commented Dec 4, 2018 at 19:45
  • What was wrong with x = x.tolist()? Commented Dec 5, 2018 at 7:05

1 Answer 1

3

"A comma between values" as in a string?

",".join(x)

if you want a true list:

x = list(x)

or

x = [i for i in x]

should do the trick

Sign up to request clarification or add additional context in comments.

1 Comment

your numpy array doesn't look like any I've ever seen before -- is it a named index? Can you send a picture? Or a print out? I've never seen one w/ a " " delim

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.