「已注销」
码龄5年
关注
提问 私信
  • 博客:13,039
    13,039
    总访问量
  • 7
    原创
  • 暂无
    排名
  • 2
    粉丝
  • 0
    铁粉
IP属地以运营商信息为准,境内显示到省(区、市),境外显示到国家(地区)
IP 属地:北京市
  • 加入CSDN时间: 2020-06-19
博客简介:

Better to Run than Curse the Road

查看详细资料
个人成就
  • 获得4次点赞
  • 内容获得1次评论
  • 获得6次收藏
创作历程
  • 8篇
    2021年
  • 14篇
    2020年
成就勋章
TA的专栏
  • Python基础
    19篇
  • Django学习
    3篇
创作活动更多

超级创作者激励计划

万元现金补贴,高额收益分成,专属VIP内容创作者流量扶持,等你加入!

去参加
  • 最近
  • 文章
  • 代码仓
  • 资源
  • 问答
  • 帖子
  • 视频
  • 课程
  • 关注/订阅/互动
  • 收藏
搜TA的内容
搜索 取消

pd.concat axis=1出现valueError报错,行数一样合并列

原因:index不同。用df.index发现,两个dataframe一个是RangeIndex, 另一个是int64。 解决方法:# 1. 将int64的index重新设置成rangeindexdf1.reset_index(inplace=True)df1.index# 2. ignore indexdf = pd.concat([df1, df2],ignore_index=True)print(df.index)...
原创
发布博客 2021.09.15 ·
628 阅读 ·
1 点赞 ·
0 评论 ·
0 收藏

奖牌RANK (python pandas)

使用dataframe的 sort_values 多列排序,全设置降序排列import pandas as pdmedal = { "金": [8, 8, 7, 10], "银": [3, 7, 5, 7], "铜": [8, 3, 7, 3], "总数": [19, 18, 19, 20],}df = pd.DataFrame(medal)rank = df.sort_values(by=["金", "银", "铜", "总数"], ascending=.
原创
发布博客 2021.07.27 ·
707 阅读 ·
0 点赞 ·
0 评论 ·
1 收藏

Pycharm 添加内容根 解决导包问题

问题:使用sys.path.append()添加路径后还是无法导包进入preferences 点击项目projects的项目结构,右边添加内容根 添加包目录 ✅
原创
发布博客 2021.03.24 ·
607 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

pytz 将date确定时区后转换成任意时区

目录0. goal1. pytz2. func3. 实例0. goal将字符串类型的日期时间, 如 "2021-03-1616:05:05" 确认为某一时区时间后,转换成北京时间。(根据个人需求去掉了时间只保留日期)1. pytz可以显示所有国家地区的各个时区,通过这个确定需要的时区pytz.all_timezonesOut[5]: ['Africa/Abidjan', 'Africa/Accra', 'Africa/Addis_Ababa', ...
原创
发布博客 2021.03.16 ·
239 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

Python发送邮件及各种附件

import smtplibfrom email.header import Headerfrom email.mime.application import MIMEApplicationfrom email.mime.multipart import MIMEMultipartfrom email.mime.text import MIMETextclass SendEmail: def __init__(self): """ 配置发件人信息 .
转载
发布博客 2021.03.03 ·
183 阅读 ·
0 点赞 ·
1 评论 ·
0 收藏

解压zip

importzipfilefile = "文件路径"zip_file = zipfile.ZipFile(file) # 读取zip文件zipfile.is_zipfile(zip_file) # 判断是否为zipprint(zip_file.namelist()) # 获取zip文档内所有文件的名称列表zip_file.extractall('输出的路径') # 解压全部文件...
转载
发布博客 2021.03.03 ·
110 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

pip->pip3, python2.7->python3.9

1. 由↓引出的问题pip3 install -r requirements.txt2.尝试更新pip解决python -m pip>>> 版本为2.7pip install --upgrade pip>>>Traceback (most recent call last): File "/usr/local/bin/pip", line 5, in <module> from pip._internal...
原创
发布博客 2021.03.02 ·
212 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

pandas读入excel 数字以00之类的开头

解决方法,直接在读入时变成strpd.read_excel("....", converters={u"以000之类开头的列名" : str})
转载
发布博客 2021.01.08 ·
766 阅读 ·
1 点赞 ·
0 评论 ·
1 收藏

error_bad_lines=False

# 跳过超出header字段的行,如4个字段,579行出现了 5个pd.read_table(, error_bad_lines=False)# 显示的跳过信息b'Skipping line 579: expected 4 fields, saw 5
'
原创
发布博客 2020.12.25 ·
4761 阅读 ·
0 点赞 ·
0 评论 ·
1 收藏

Role of Underscore (_)

1. interpreter里使用 as a particular variable>>> 5 + 49>>> _ # stores the result of the above expression9>>> _ + 615>>> _15>>> a = _ # assigning the value of _ to another variable>>> a15
翻译
发布博客 2020.12.17 ·
104 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

替换多个字符

import unicodedatas = 'aac1233xyz'[in]t2 = s.translate({ord('a'): 'X', ord('3'): 'Y'}) print(t2)[out] XXc12YYxyz[in]t3 = s.translate({ord('a'): None, ord('3'): None}) print(t3)[out]c12xyz
转载
发布博客 2020.12.17 ·
173 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

get column index

1.创建个dfdf = DataFrame({"pear": [1,2,3], "apple": [2,3,4], "orange": [3,4,5]})2.获取列名df.columns3.获取列的indexdf.columns.get_loc("pear")
翻译
发布博客 2020.12.16 ·
442 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

**args **kw

参考https://www.jianshu.com/p/0ed914608a2c脚本:https://github.com/WENHUIn/python3.7/blob/main/*arg%26**kw.py
转载
发布博客 2020.12.16 ·
73 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

TypeError: xxx takes 1 positional argument but 9 were given 【multiprocess】

args=(i)不是tupleargs=(i,)通过添加逗号,形成tupleAdd a comma; tuples are formed by the comma, not the parentheses (although you need parentheses to disambiguate the tuple from other arguments in a call)
翻译
发布博客 2020.12.11 ·
1619 阅读 ·
2 点赞 ·
0 评论 ·
0 收藏

时间戳转时间 & 时间转时间戳

1. 时间戳转时间 【毫秒转】import datetimedef transfer_to_localtime(unix): localtime = datetime.datetime.fromtimestamp(unix / 1000) return localtimeEg:unix = 1605280519000date = transfer_to_localtime(unix)print(date)2020-11-13 23:15:192. 时间转时..
转载
发布博客 2020.12.03 ·
473 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

Django 【Model】【坑】

1. 问题:TypeError: __init__() missing 1 required positional argument: 'on_delete'classForeignKey(to,on_delete,**options)[source]¶A many-to-one relationship. Requires two positional arguments: the class to which the model is related and theon_deleteo...
翻译
发布博客 2020.12.02 ·
201 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

Django 链接MySQL 【坑】

1. -bash: mysql: command not foundhttps://www.jianshu.com/p/ba22165965692.django.db.utils.OperationalError: (1049, "Unknown database 'mydatabase'") 报错mysql> create database mydatabase character set uft8;https://blog.csdn.net/lo_bamboo/articl..
转载
发布博客 2020.11.27 ·
181 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

PYTHONPATH for import

1.在终端里使用export PYTHONPATH="文件夹路径"2. 检查是否设置完成路径echo $PYTHONPATH
翻译
发布博客 2020.11.27 ·
273 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

transfer脚本 【如何跳过异常值继续执行】【删除unnamed列】【字典遍历】

1.目标:将一串json格式字符串分列 该字符串位于dataframe的data列{"score": 527, "features": {"GD_M_103": 9.0, "GD_M_246": 70.0, "GD_M_238": 0.0, "GD_M_315": 11.0, "GD_M_107": 4.0, "GD_M_319": 6.0, "GD_M_2": 19.0, "GD_M_72": 1.0, "GD_M_60": 0.0, "GD_M_82": 1.0, "GD_M_6": 2.0.
原创
发布博客 2020.11.26 ·
152 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

convert string to dict

1. 使用 literal_evalfrom ast import literal_evalpython_dict = literal_eval("{'a': 1}")2. 使用 json.loads() 【注意,字符串必须为double quotes】import jsonpython_dict = json.loads('{"a": 1}')
转载
发布博客 2020.11.26 ·
102 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏
加载更多