上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 24 下一页
摘要: #!/usr/bin/env python3 # coding: utf-8 import datetime def last_day_of_month(any_day): """ 获取获得一个月中的最后一天 :param any_day: 任意日期 :return: string """ next 阅读全文
posted @ 2020-05-05 21:08 cup_leo 阅读(1817) 评论(0) 推荐(1)
摘要: LabelEncoder可以将标签分配一个0—n_classes-1之间的编码 将各种标签分配一个可数的连续编号 将DataFrame中的每一行ID标签分别转换成连续编号: import pandas as pd from sklearn.preprocessing import LabelEnco 阅读全文
posted @ 2020-04-30 20:53 cup_leo 阅读(1270) 评论(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 阅读(1936) 评论(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 阅读(1224) 评论(0) 推荐(0)
摘要: res.groupby(['customer_id'])['project_name'].apply(lambda x:', '.join(x)).reset_index() x.groupby(['sa'])['daList'].apply(lambda x:np.concatenate(list 阅读全文
posted @ 2020-02-06 18:22 cup_leo 阅读(1170) 评论(0) 推荐(0)
摘要: #多个单元格合并成一列 def ab(df): return', '.join(df.values) #剔除空字符或者空值 data = data[(data['project'].isnull()==False) & (data['project']!='')] data1 = data.grou 阅读全文
posted @ 2019-12-25 08:45 cup_leo 阅读(4000) 评论(0) 推荐(0)
摘要: SELECT t.*, CASE WHEN t.SaleDealMoney_last IS NULL OR t.SaleDealMoney_last=0 THEN 0 ELSE FORMAT(((t.SaleDealMoney_this-t.SaleDealMoney_last)/t.SaleDea 阅读全文
posted @ 2019-12-20 08:45 cup_leo 阅读(976) 评论(0) 推荐(0)
摘要: def FuncRecursive(len_curr=0, sen_odd=[], sen_curr=[]): """ 递归函数,将形如 [['1'], ['1', '2'], ['1']] 的list转为 ['111','121'] :param count: int, recursion tim 阅读全文
posted @ 2019-11-20 10:41 cup_leo 阅读(281) 评论(0) 推荐(0)
摘要: 原文 : https://cloud.tencent.com/developer/ask/188486 import os, sys class HiddenPrints: def __enter__(self): self._original_stdout = sys.stdout sys.std 阅读全文
posted @ 2019-11-16 20:45 cup_leo 阅读(804) 评论(0) 推荐(0)
摘要: 高效方法:dfs[dfs['delta'].isnull()==False].sort_values(by='delta', ascending=True).groupby('Call_Number', as_index=False).first() 阅读全文
posted @ 2019-10-30 13:36 cup_leo 阅读(3540) 评论(0) 推荐(0)
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 24 下一页