Last active
February 19, 2019 02:43
-
-
Save PortWhisperer/a54a4e876ec82ab2049e17559b9433ea to your computer and use it in GitHub Desktop.
questions for #python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # how can i get just the values instead of the array objects ? | |
| { | |
| "cluster" + str(int(i) + 1): i | |
| for i in clust_obj.predicted_clusters[["cluster"]].values[range(len(clust_obj.predicted_clusters))] | |
| } | |
| Out[40]: | |
| {'cluster2': array([1]), | |
| 'cluster3': array([2]), | |
| 'cluster7': array([6]), | |
| 'cluster1': array([0]), | |
| 'cluster6': array([5]), | |
| 'cluster5': array([4]), | |
| 'cluster4': array([3])} | |
| # attempt 2 | |
| { | |
| "cluster" + str(int(i) + 1): i | |
| for i in clust_obj.predicted_clusters[["cluster"]].values | |
| } | |
| Out[26]: | |
| {'cluster2': array([1]), | |
| 'cluster3': array([2]), | |
| 'cluster7': array([6]), | |
| 'cluster1': array([0]), | |
| 'cluster6': array([5]), | |
| 'cluster5': array([4]), | |
| 'cluster4': array([3])} | |
| # attempt 3 | |
| { | |
| "cluster" + str(int(i) + 1): i | |
| for i in clust_obj.predicted_clusters[["cluster"]].values[range(len(clust_obj.predicted_clusters))[0]] | |
| } | |
| Out[44]: {'cluster2': 1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
solution:
cluster_labels = {
"cluster" + str(int(i) + 1): i[0]
for i in clust_obj.predicted_clusters[["cluster"]].values[range(len(clust_obj.predicted_clusters))]
}