I want to resolve TypeError: unhashable type:'numpy.ndarray'
Please write the details of the question here.
I would like to sort two columns in ascending order like Excel, and rearrange the order in the other column
Should I make a companion into a dictionary?
Applicable source code
TypeError: unhashable type: 'numpy.ndarray'
import pandas as pd import numpy as np # Load file # Need to match the environment df = pd.read_csv (r'C: \ pytrategy \ mfmdb02.csv ', encoding = "cp932", index_col = 0, engine =' python ') triggers = ['gap'] targets = ['gap1'] xa = df [triggers] .as_matrix () [1: -1] ya = df [targets] .as_matrix () [1: -1] za = dict (zip (xa, ya))
Answer # 1
It may not be the answer you want, but ...
I want to sort two columns in ascending order like Excel, and rearrange the order in another column
If you don't have a bad dictionary,
Isn't it good to use
df = df.sort_values ('gap') print (df)
Answer # 2
How about this?
import numpy as np original = 1 + np.arange (5) order = np.array ([1, 2, 3, 0, 4]) index = np.argsort (order) sorted = original [index] print (original) print (order) print (index) print (sorted)
original = targets
order = triggers
I hope you can.
- when you want to create a python dictionary name with for syntax
- python 3x - i want to install numpy with python 38
- python 3x - how to change the value of the data frame
- python - i'm not using numpy, but i get a numpy error
- python - [django] how to display dictionary data in templates file
- python - i want to dynamically change the label on the tkinter gui by processing the for loop
- how to access if list is inside python dictionary
- i want to change the image drawn in rgb using python matplotlib to hsv
- python 3x - to change the date format when writing a data frame
- python - [numpy] i don't understand the mechanism of product of matrices of one-dimensional arrays
- python - i want to divide a list that contains multiple lists
- i want to change the display format of date by using regular expression in python
- python 3x - i want to change the style, but only i get a "resource exhausted error"
- python - goo japanese dictionary scraping
- image reading with numpy in python
- python - i want to change optional arguments according to conditions
- python x axis change
- python - i want to delete multiple columns at the same time with numpy
- python - how to read multiple lists in for statement
- python 3x - i want to change the position to add reaction in discordpy
- python - i would like to know why the capacity changes when i load an image and just save it
- python - i want to sort a 2d array
- python - regarding how to handle the list output string as a list type
- i want to process sql data in python and create a graph (i made it, but it is heavy)
- python - optuna light-library import error in gbm parameter tuning
- i don't know how to output python predicted value
- i want to compare the size of elements surrounded by grid lines in python
- please add a python error
- about python find and find_all
- python - how to inherit dictionary type