Home > OS >  plt.plot TypeError: unhashable type: 'numpy.ndarray'
plt.plot TypeError: unhashable type: 'numpy.ndarray'

Time:10-08

I want to implement the butterworthfilter with python in jupyter Notebook. Python is new to me and i dont know why i get a error. I search here but i didnt find a solution.

The data are from a CSV-File, it calls Samples.csv

The Data in Samples.csv are like

998,4778415
1009,209592
1006,619094
1001,785406
993,9426543
990,1408991
992,736118
995,8127334
1002,381664
1006,094429
1000,634799
999,3287747
1002,318812
999,3287747
1004,427698
1008,516733
1007,964781
1002,680906
1000,14449
994,257009

The column calls Euclidian Norm. The range of the data are from 0 to 1679.286158 and theyre are 1838 rows.

I wrote this code, it was from a tutorial.

from scipy.signal import filtfilt
from scipy import stats

import csv
import pandas as pd
import numpy as np

import matplotlib.pyplot as plt
import scipy

def plot():
    data=pd.read_csv('Samples.csv',sep=";")
    sensor_data=data[['Euclidian Norm']]
    sensor_data=np.array(sensor_data)
    
    time=np.linspace(0,1679.286158,1838)
    plt.plot(time, sensor_data)
    plot.show()
plot()

I get the error TypeError: unhashable type: 'numpy.ndarray'and the line of plt.plot(time, sensor_data) it marks yellow.

I dont know what is wrong, because i dont see a type failure in the code, does anyone know what could be wrong in the code?

CodePudding user response:

The problem is that you are using , as the decimal separator in your CSV file but you haven't told Pandas that you are doing that.

Try replacing the line

    data=pd.read_csv('Samples.csv',sep=";")

with

    data=pd.read_csv('Samples.csv',sep=";", decimal=",")
  • Related