COZYHUB
  • Home
  • Disclaimer
  • Privacy Policy
  • About
  • Contact

Unable to ravel a numpy array


I have a numpy arrayx = np.array([145100, [ 1,2,3 ], 100.6])and I wish to ravel it to this:[145100, 1,2,3 , 100.6]

I tried this, but it didn't gave any results:

x = np.ravel(x)

As the shape was still (3,) instead of (5,). What am I missing?

1

Best Answer


Use numpy.hstack:

import numpy as npx = np.array([145100, [ 1,2,3 ], 100.6])x = np.hstack(x)
array([1.451e+05, 1.000e+00, 2.000e+00, 3.000e+00, 1.006e+02])

Random Posts

Identify which USB device is /dev/ttyUSB0javascript websocket onmessage event.dataDoes the unary + operator have any practical use?Angular 6 : Real time dataDart - How to format DateTime based on device timezone?Difference of sizeof(float) C++SQL Queries "00904. 00000 - "%s: invalid identifier"How to use std::invoke_result_t to get return type of a functionHow to deserialize an anonymous object using C# System.Text.Json and access its properties?Which Python memory profiler is recommended? [closed]Pop (LPOP, RPOP) multiple keys with one commandEconometrics : White Test with RHow to use the SSH key for Bitbucket projects?Passing variable into included twig template that has variable in template nameiptables with docker blocking incoming traffic, allowing outgoing trafficQnA Maker "Context Only" not working in live Bot or Emulatorrun go test command on multiple testfiles with go.work fileHow to add fonts to create-react-app based projects?CSS opacity - background colourHow to install Python packages for Spyder
Designed by COZYHUB