0

How can I extend two ndarrays ?

for instance,

df = np.fromfile(f"/data/8d6ea70b_bitmex_XBTUSD_0001.dat", dtype)

df.extend( np.fromfile(f"/data/8d6ea70b_bitmex_XBTUSD_0002.dat", dtype) )
3
  • 1
    I neither see two numpy arrays in your post, nor the expected output or your attempt. Commented Nov 18, 2018 at 20:54
  • docs.scipy.org/doc/numpy-1.15.0/reference/generated/… Commented Nov 18, 2018 at 20:56
  • 3
    Numpy arrays don't have an extend method. They aren't lists. There is a poorly named np.append, but I prefer that people use np.concatenate. But take time to read its docs. Commented Nov 18, 2018 at 21:52

1 Answer 1

4

To concatenate two numpy arrays, use concatenate:

v1 = np.fromfile(f"/data/8d6ea70b_bitmex_XBTUSD_0001.dat", dtype)
v2 = np.fromfile(f"/data/8d6ea70b_bitmex_XBTUSD_0002.dat", dtype)
v = np.concatenate((v1, v2))

Then use them for a dataframe (your question being concatenating numpy arrays, not dataframes).

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

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.