Python
文章平均质量分 69
Python works
dénnnnnnnnnnn
这个作者很懒,什么都没留下…
展开
-
[Python-Numpy] 转换Dictionary/Dict Array为Numpy Array
import numpy as np # Creating a Dictionary dict = {1: 'Geeks', 2: 'For', 3: 'Geeks'} result = dict.items() # 此处可根据情况选择.values or .keys data = list(result) numpyArray = np.array(data)原创 2022-03-29 09:52:38 · 1836 阅读 · 0 评论 -
[GeneralAlgorithm] Binary Tree Algorithm 单链表算法 (in Python)
Binary Tree Algorithm (in Python) 简易二叉树算法,包含可视化打印,附三类顺序表达和额外查找方法。 最后一部分代码用以根据两种 data orders (inorder & preorder) 识别并创建Binary tree object. class BinaryTree: def __init__(self, rootElement): self.key = rootElement self.left = None原创 2020-12-01 12:59:12 · 143 阅读 · 0 评论 -
[GeneralAlgorithm] Single-linked List Algorithm 单链表算法 (in Python)
Single-linked List Algorithm (in Python) 简易单链表算法,携Sample Test部分 class SLinkedListNode: def __init__(self, initData, initNext): self.data = initData self.next = initNext def getNext(self): return self.next def getData(s原创 2020-12-01 11:15:16 · 83 阅读 · 0 评论 -
[GeneralAlgorithm] Double-linked List Algorithm 双链表算法 (in Python)
Double-linked List Algorithm (in Python) 简易双链表算法,部分功能待补充。 class DLinkedListNode: def __init__(self, initData=None, initNext=None, initPrevious=None): self.data = initData self.next = initNext self.previous = initPrevious原创 2020-12-01 11:08:48 · 106 阅读 · 0 评论 -
[GeneralAlgorithm] Circular Queue Algorithm 循环队列算法 (in Python)
Circular Queue Algorithm (in Python) 简易循环队列算法 class CircularQueue: def __init__(self, capacity): """ Constructor, which creates a new empty queue. """ # Check validity of capacity type and value if type(capacity)原创 2020-12-01 12:35:08 · 84 阅读 · 0 评论 -
[GeneralAlgorithm] Stack Algorithm 栈算法 (in Python)
Stack Algorithm (in Python) 栈算法,携Sample Test部分 class Stack: def __init__(self): self.items = [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self):原创 2020-12-01 12:51:33 · 109 阅读 · 0 评论 -
[GeneralAlgorithm] Bounded Queue Algorithm 有界队列算法 (in Python)
Bounded Queue Algorithm (in Python) 简易有界队列算法,携Sample Test部分 class BoundedQueue: def __init__(self, capacity): assert isinstance(capacity, int), ('Error: Type error: {}'.format(type(capacity))) self.__items = [] self.__capacity原创 2020-12-01 12:35:46 · 171 阅读 · 0 评论 -
【Notes】数据常用操作随笔
本人曾粗略学过numpy核心语法以及python的数据操作,但是奈何许久不写python了,并且np所学真到用时却不知很多功能如何实现。借此原因创建随笔,更新做Optimization过程中遇到的常用功能表达(py/py_np/RL/ML)。 *列出仅为常见用法,更多见Google 1/ np.argwhere(关于矩阵筛选条件) np.argwhere(X >1) Return:返回该矩阵下符合此条件的元素序列 格式为数组: (1D --> 一阶数组)[x, y, z] (2D --&g原创 2022-02-05 10:26:27 · 1093 阅读 · 0 评论