Convert dict to array

When you have features in dict and want to make an array format vector like that used in scipy or scikit-learn

from sklearn.feature_extraction import DictVectorizer

features = [{"poko":2, "hoge":1}, {"hoge":2, "pokopoko":10}, {"poko":5, "hogehoge":1}]
vec = DictVectorizer()
array_vectors = vec.fit_transform(features).toarray()

I can go. When you want to see the feature label

vec.get_feature_names()

so

Recommended Posts

Convert dict to array
Convert array (struct) to json with golang
Convert 202003 to 2020-03 with pandas
Convert kanji to kana
Convert jupyter to py
Convert keras-yolo3 to onnx
Convert a multidimensional list (array) to one dimension
Convert json to excel
Convert NumPy array "ndarray" to lilt in Python [tolist ()]
Convert Webpay Entity type to Dict type (recursively in Python)
Convert elements of numpy array from float to int
Convert hexadecimal string to binary
[python] Convert date to string
Convert numpy int64 to python int
[Python] Convert list to Pandas [Pandas]
Convert HTML to text file
Convert Scratch project to Python
[Python] Convert Shift_JIS to UTF-8
Convert IP address to decimal
Convert SDF to CSV quickly
Convert genbank file to gff file
Convert python 3.x code to python 2.x
How to convert an array to a dictionary with Python [Application]
Convert .ipynb to .html (with BatchFile)
Function to convert Excel column to number
Convert PDF to Documents by OCR
Subscript access to python numpy array
Convert markdown to PDF in Python
Convert wma to mp3 on Mac
numpy: I want to convert a single type ndarray to a structured array
Convert some Japanese names to antonyms
convert ggplot based graph to html
Workflow to convert formula (image) to python
Convert sentences to vectors with gensim
How to convert 0.5 to 1056964608 in one shot
Python> list> Convert double list to single list
Convert from pdf to txt 2 [pyocr]
[Python] How to swap array values
How to convert Tensorflow model to Lite
Convert a string to an image
[Python] Convert natural numbers to ordinal numbers
Convert decimal numbers to n-ary numbers [python]
Convert the result of python optparse to dict and utilize it
Program to convert Japanese to station name
How to convert from .mgz to .nii.gz
Convert PDF to image with ImageMagick
A tool to convert Juniper config
Python> tuple> Convert double tuple to single tuple
[Python] How to convert db file to csv
Convert memo at once with Python 2to3
How to easily convert format from Markdown
Convert Python> two value sequence to dictionary
[Django] Convert QuerySet to dictionary type list
[Python] How to convert a 2D list to a 1D list
How to convert csv to tsv in CLI
How to convert Python to an exe file
Convert matplotlib graphs to emf file format
[Python] Convert csv file delimiters to tab delimiters
Convert GFF3 to MSS for DDBJ submission
Convert (compress) formatted JSON string to 1-line JSON
Convert psd file to png in Python