会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
cup_leo
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
13
14
15
16
17
18
19
20
21
···
24
下一页
2020年5月5日
判断当天是否为月末
摘要: #!/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)
2020年4月30日
使用sklearn之LabelEncoder将Label标准化
摘要: 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)
2020年2月18日
pyrhon 技巧 解析pymysql查询结果,取mysql其中的某一列数据 zip解压
摘要: 一般用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)
python list tuple 如何传参 正确使用MySQL where in ()
摘要: 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)
2020年2月6日
pandas 分组 合并多个元素
摘要: 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)
2019年12月25日
python pandas 行转列 一个单元格多个字符串转成一列 列转行
摘要: #多个单元格合并成一列 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)
2019年12月20日
MySQL 环比计算
摘要: 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)
2019年11月20日
中文数据增强 同义句 扩展
摘要: 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)
2019年11月16日
禁止打印调用(python)
摘要: 原文 : 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)
2019年10月30日
pandas 排序 分组 筛选某一列最大值最小值 sort_values、groupby、max、min
摘要: 高效方法: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
下一页
公告