随笔分类 -  python 技巧

摘要:def frequent_words(tdf,k): words = ' '.join(tdf['OriginalTweet'].apply(lambda x:' '.join(x)).values.flatten()).split(' ') freq = nltk.FreqDist(words) 阅读全文
posted @ 2023-03-04 09:24 cup_leo 阅读(14) 评论(0) 推荐(0) 编辑
摘要:#定义合并函数:将有共同核心点的临时聚类簇合并 test_list_set = [{1,2,3},{3,4,5},{10,12,13},{4,5,8},{13,15},{7,8},{20,22}] result = [] for index, t0 in enumerate(test_list_se 阅读全文
posted @ 2021-12-08 16:28 cup_leo 阅读(67) 评论(0) 推荐(0) 编辑
摘要:import time from datetime import datetime def getBetweenDay(begin_date,end_date): date_list = [] begin_date = datetime.strptime(begin_date, "%Y-%m-%d" 阅读全文
posted @ 2020-07-09 09:37 cup_leo 阅读(1093) 评论(0) 推荐(0) 编辑
摘要:一般用python查询MySQL后,返回的结果是list或者tuple,如何取某一列数据呢? mysql的返回值可以是tuple也可以是dict,常用的时tuple。 有时候想要根据前一个SQL的结果去生成另一个SQL,比如: sql1 = select id,name from article l 阅读全文
posted @ 2020-02-18 10:30 cup_leo 阅读(1914) 评论(0) 推荐(0) 编辑
摘要:param = [1,2,3] #或者 param = [‘1’,‘2’,‘3’] sql_in = """ SELECT id,customer_number,customer_name from customer_info where id in {} """.format(tuple(para 阅读全文
posted @ 2020-02-18 10:24 cup_leo 阅读(1202) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示