笔记

2020.5.28

  1. excel/csv文件中,使用“单元格”&“单元格”可以实现多个单元格字符的连接,比如A1:"121",B1:“你好”,C1中输入A1&B1就可以得到"121你好"
  2. 用Python解决批量问题的核心,在于梳理并解决单个问题,然后批量循环
  3. pd.concat(A,B)用于合并两个表

 

 

2020.05.30

异常类型1

主动抛出异常

def password():
    pwd = input("pls input pwd:
")
    if len(pwd) >= 8:
        return pwd
    print("主动抛出异常")
    ex = Exception("密码长度过短")
    raise ex

try:
    print(password())
except Exception as result:
    print(result)

2021.02.18

ndarray数据类型,使用list()可以遍历

e.g. 

temp1 = DBSCAN(eps = 1, min_samples = 5, metric = 'euclidean').fit(dataset1)

temp1为ndarray.float64的对象,使用list(temp1)可以将temp1转化为list对象,进行遍历取值

labels1 = list(temp1.labels_)

如果去某个特定值进行计数,e.g. '-1'

则labels1.count(-1)

原文地址:https://www.cnblogs.com/yuyukun/p/12977690.html