我的代码生成以下错误: TypeError: object() takes no parameters
class Graph(object):
def vertices(self):
return list(self.__graph_dict.keys())
if __name__ == "__main__":
g = { "a" : ["d"],
"b" : ["c"],
"c" : ["b", "c", "d", "e"],
"d" : ["a", "c"],
"e" : ["c"],
"f" : []
}
graph = Graph(g)
print("Vertices of graph:")
print(graph.vertices())
Run Code Online (Sandbox Code Playgroud)
有没有办法解决这个问题?
我有这段代码:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(data.FAC1_1, data.FAC2_1, data.FAC3_1, c='r', marker='o')
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
plt.show()
Run Code Online (Sandbox Code Playgroud)
一切正常。唯一的问题是出来的散点图真的很小。有没有办法让它变大?我查看了文档,但找不到它。
谢谢你
这是我的代码.
from sklearn.cluster import DBSCAN
dbscan = DBSCAN(random_state=111)
dbscan.fit(data3)
Run Code Online (Sandbox Code Playgroud)
data3是一个pandas数据帧:
FAC1_2 FAC2_2
0 -0.227252 -0.685482
1 0.015251 -0.988252
2 -0.291176 -0.696146
3 -0.747702 -0.708030
4 -0.648103 -0.701741
5 -0.546777 -0.906151
6 -0.141553 -0.689223
7 0.159203 -0.734537
8 0.345847 -0.900163
9 -0.049349 -0.700356
10 0.079924 -0.651371
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
File "/anaconda/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py", line 1632, in _maybe_convert_indices
raise IndexError("indices are out-of-bounds")
IndexError: indices are out-of-bounds
Run Code Online (Sandbox Code Playgroud)
问题是什么?