1

I have two tables that each contain columns of latitude and longitude coordinates (thus they're all floats), so four columns all day. My first goal was to concatenate the respective columns together so as to have just one table, with two longer columns containing everything.

Bear with me, I'm not using pandas, but essentially a dumbed-down module called datascience.

Attempt one looks like

test_list = np.concatenate(airbnb.column('latitude'), stations.column('latitude'))

but I get back TypeError

Traceback (most recent call last)
 <ipython-input-27-8a5f584e9d8f> in <module>
 ----> 1 test_list = np.concatenate(airbnb.column('latitude'), stations.column('latitude'))
 <__array_function__ internals> in concatenate(*args, **kwargs)
TypeError: only integer scalar arrays can be converted to a scalar index

any suggestions?

1
  • Welcome to Stackoverflow! Please paste some lines (5-10) lines of sample data so that people can copy it and produce their solutions based on that. This will help you get reproducible solutions. Commented Dec 4, 2019 at 15:48

2 Answers 2

2

You want to put brackets around the two values as such for it work the way you want:

test_list = np.concatenate([airbnb.column('latitude'), stations.column('latitude')])

The error:

TypeError: only integer scalar arrays can be converted to a scalar index

is because the second argument is for which axis to concatenate e.g. 0 or 1, which shows the error when you a provide an array for axis.

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

Comments

1

The issue would have been raised in both pandas and datascience packages .

The issue is with arguments passed to np.concatenate.

np.concatenate takes 1st argument as sequence of array_like.

So it must be something like user1321988 mentioned :

list

A bracket would work :

test_list = np.concatenate([airbnb.column('latitude'), stations.column('latitude')])

Upvote if works

Comments

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.