![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
自由的行走
向着有光的地方出发!!!
展开
-
pandas dataframe 一列数据变多列
一、问题描述希望把dataframe 中的一列数据分割为多列追加到dataframes上分割前示意图分割后效果图二、代码实现#提取出分割列的名称,或者可以自己定义分割后的列名称feature_name = data.columns[-1].split(",")#是用expand属性进行分割data[feature_name] = data[data.columns[-1]].str.split(',', expand=True)#目标列名称feature_nam.原创 2021-09-03 19:54:50 · 2146 阅读 · 0 评论 -
pd_to_datetime将时间戳转换日期格式,日期不正确
一、问题描述笔者需要将时间戳数据转换成日期格式,使用的是pd_to_datetime进行转换,得到了如下图结果data["date_"] = pd.to_datetime(data["timestamp"],unit = "ms")一眼看上去是转换正确了,但使用线上的工具进行验证时出现了不一致性二、原因分析线上的工具和使用pd_to_datetime转换得到的时间刚好相差8个小时,初步感觉是时区出现了问题,希望通过阅读文档找到如何去修改时区的属性但经过查看pd_to_da...原创 2021-09-03 14:26:29 · 5460 阅读 · 4 评论 -
查看xgboost版本
>> import xgboost as xgb>> xgb.__version__原创 2021-08-20 11:43:34 · 3306 阅读 · 0 评论 -
MAC-OS使用xgboost时报错
import xgboost时出现如下错误XGBoostError: XGBoost Library (libxgboost.dylib) could not be loaded.Likely causes: * OpenMP runtime is not installed (vcomp140.dll or libgomp-1.dll for Windows, libomp.dylib for Mac OSX, libgomp.so for Linux and other UNIX-like.原创 2021-08-13 16:09:05 · 1397 阅读 · 0 评论 -
常用的激活函数代码实现
本文主要是常用的激活函数的实现,侧重于工程方面 没有过多的理论介绍 想要了解理论的可以参考:常用激活函数(激励函数)理解与总结神经网络激活函数汇总(Sigmoid、tanh、ReLU、LeakyReLU、pReLU、ELU、maxout)#Sigmoid 函数import numpy as npdef Sigmoid(z): fz = 1 / (1+np.exp(-z))...原创 2019-11-17 18:30:57 · 1282 阅读 · 0 评论 -
统计 THE TRAGEDY OF ROMEO AND JULIET (罗密欧与朱丽叶)英文小说中各单词出现的次数
作为python 练手的一个小例子数据来源:链接:https://pan.baidu.com/s/1u2c7O-617MboXSwBHnoOcA 提取码:vX47def words_static(file_path): words_static = dict() with open(file_path,"r") as file : for line...原创 2019-10-31 10:43:15 · 1642 阅读 · 0 评论 -
pandas.read_csv参数整理
pandas.read_csv参数整理转载读取CSV(逗号分割)文件到DataFrame也支持文件的部分导入和选择迭代更多帮助参见:http://pandas.pydata.org/pandas-docs/stable/io.html参数:filepath_or_buffer: str,pathlib。str, pathlib.Path, py._path.local.L...转载 2019-09-14 21:29:07 · 174 阅读 · 0 评论 -
Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools":
在学习推荐系统开源项目 surprise 时 Pip 安装出错 秉承真正的勇士敢于直面问题的精神 我查阅了相关的资料参考网上种种解决方法 均不理想当我要下载官网 下载工具时 4G大小 让我一个在校生止步 我放弃了 【捂脸】我最终还是选择了绕道而行 使用 conda install xxxxxconda install -c conda-forge scikit-surpri...原创 2019-09-12 22:20:04 · 233 阅读 · 0 评论 -
LeetCode 1154. Day of the Year
import datetimeclass Solution: def dayOfYear(self, date: str) -> int: time=date.split("-") year=int(time[0]) mon=int(time[1]) day=int(time[2]) d1 = dat...原创 2019-08-14 22:44:34 · 219 阅读 · 0 评论 -
LeetCode 125. Valid Palindrome
class Solution(object): def isPalindrome(self, s): """ :type s: str :rtype: bool """ intable=string.punctuation outtable=" "*len(intable) ...原创 2019-08-14 18:01:40 · 77 阅读 · 0 评论 -
LeetCode 859. Buddy Strings
class Solution: def buddyStrings(self, A: str, B: str) -> bool: """有且仅有2个字符交换后 让A&B相等""" if len(A)!=len(B): return False if A==B: if len(A)&...原创 2019-08-03 17:41:35 · 79 阅读 · 0 评论 -
LeetCode 1108. Defanging an IP Address
import reclass Solution: def defangIPaddr(self, address: str) -> str: """这个简单 正则字符串 替换""" return re.sub("\.","[.]",address)提交时间:2019-08-03 16:48...原创 2019-08-03 16:49:14 · 110 阅读 · 0 评论 -
LeetCode 686. Repeated String Match
class Solution: def repeatedStringMatch(self, A: str, B: str) -> int: if set(A)<set(B): #如果字符串B中出现A中没有的元素 则无论如何重复都不可能 直接返回-1 return -1 for i in range(1,int(len(B)...原创 2019-08-03 16:36:24 · 89 阅读 · 0 评论