Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in Python by (19.9k points)

I am currently working on some scientific data and I am trying to perform a clustering task on it but I get a Value error due to the the format of the data. Which is two Pandas DataFrames in [170 rows x 7 columns].

#x is the y distance

x = np.empty(7, dtype = object)

x[:] = [distance_lC, distance_fC]

#y is the speed.

y = np.empty(7, dtype = object)

y[:] = [speed_lC, speed_fC]

cell_kmeans = KMeans(n_clusters = 4).fit_predict(y)

fig = plt.figure()

ax = fig.add_subplot(1,1,1)

ax.scatterplot(cell_kmeans)

plt.show()

The output should give out the cluster. But I have the following Value Error: "ValueError: setting an array element with a sequence."

1 Answer

0 votes
by (25.1k points)
edited by

You need to contact the two data frames into one before using them. You can use pandas.concat() methods to merge two data frames into one. Like this:

y = pandas.concat([speed_lC, speed_fC])

To know more about this you can have a look at the following video:-

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...