'Python error: 'str' object has no attribute 'decode'

Code:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('ggplot')
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
from sklearn.metrics import classification_report
from sklearn.metrics import accuracy_score
df_mridula = pd.read_csv ('heart.csv')
X = df_mridula.iloc[:, 1:-1].values
Y = df_mridula.iloc[:, -1].values
#splitting the data 
trainX,testX,trainY,testY =train_test_split(X, Y, test_size=0.4, shuffle=False)

#splitting the data 
trainX,testX,trainY,testY =train_test_split(X, Y, test_size=0.4, shuffle=False)

when I run this line

trainX,testX,trainY,testY =train_test_split(X, Y, test_size=0.4, shuffle=False)

I get this error. I tried pip install -h5py also but it was not fixed.

AttributeError: 'str' object has no attribute 'decode'



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source