Convert data with shape (number of data, 1) to (number of data,) with numpy.

It is often used for label data in machine learning. There will be a faster way to write

python


>>> import numpy as np
>>> y = np.array([[1], [1], [0], [1], [0]])
>>> y
array([[1],
       [1],
       [0],
       [1],
       [0]])
>>> z = np.array([x for x in y])
>>> z
array([1, 1, 0, 1, 0])

Recommended Posts

Convert data with shape (number of data, 1) to (number of data,) with numpy.
Convert Excel data to JSON with python
Convert FX 1-minute data to 5-minute data with Python
Convert "number" of excel date to python datetime
Convert 202003 to 2020-03 with pandas
How to convert horizontally held data to vertically held data with pandas
Convert elements of numpy array from float to int
Artificial data generation with numpy
Convert numpy int64 to python int
[Homology] Count the number of holes in data with Python
Try to extract the features of the sensor data with CNN
Convert .ipynb to .html (with BatchFile)
Function to convert Excel column to number
How to deal with imbalanced data
How to deal with imbalanced data
Convert list to DataFrame with python
Convert sentences to vectors with gensim
How to Data Augmentation with PyTorch
Convert PDF to image with ImageMagick
How to extract features of time series data with PySpark Basics
Made it possible to convert PNG to JPG with Pillow of Python
Save the results of crawling with Scrapy to the Google Data Store
Convert a large number of PDF files to text files using pdfminer
Output csv with different number of digits for each column with numpy
Convert xml format data to txt format data (yolov3)
Use shutil to delete all folders with a small number of files
Convert from PDF to CSV with pdfplumber
Convert character strings to features with RoBERTa
[MNIST] Convert data to PNG for keras
Convert Hiragana to Romaji with Python (Beta)
Try to image the elevation data of the Geographical Survey Institute with Python
Use pandas to convert grid data to row-holding (?) Data
Send data to DRF API with Vue.js
Get the number of visits to each page with ReportingAPI + Cloud Functions
Try converting to tidy data with pandas
Convert PDF files to PNG files with GIMP
Convert array (struct) to json with golang
Recommendation of Altair! Data visualization with Python
Convert HEIC files to PNG files with Python
Convert Chinese numerals to Arabic numerals with Python
Expand any number of arguments with yasnippet
Read a character data file with numpy
[Python --open3d] How to convert obj data of 3D model to point cloud
How to read problem data with paiza
Example of efficient data processing with PANDAS
Count the number of characters with echo
[Introduction to Data Scientists] Basics of Python ♬
Sample to convert image to Wavelet with Python
Set the number of elements in a NumPy one-dimensional array to a power of 2 (0 padded)
Summary of how to read numerical data with python [CSV, NetCDF, Fortran binary]
Find out how to divide a file with a certain number of lines evenly
Convert csv, tsv data to matrix with python --using MovieLens as an example
Convert Mobile Suica usage history PDF to pandas Data Frame format with tabula-py
An introduction to data analysis using Python-To increase the number of video views-
Align the number of samples between classes of data for machine learning with Python
[Introduction to Python] How to get the index of data with a for statement
Convert DICOM to PNG with Ascending and Descending
Try to aggregate doujin music data with pandas
Upload a large number of images to Wordpress
Convert PDF to image (JPEG / PNG) with Python
Convert PDFs to images in bulk with Python