'python' engine because the 'c' engine does not support regex separators

2018-10-2 杜世伟 Python

moveielens.py:17: ParserWarning: Falling back to the 'python' engine because the 'c' engine does not support regex separators (separators > 1 char and different from '\s+' are interpreted as regex); you can avoid this warning by specifying engine='python'.
  user = pd.read_table(path1, sep='::', header=None, names=unames)

  pandas.read_table()函数,读取文件数据时,由于分隔符为'::',弹出如下警告
       警告:ParserWarning: Falling back to the 'python' engine because the 'c' engine does not support regex separators (separators > 1 char and different from '\s+' are interpreted as regex)
       解决方法:增加函数的引擎参数engine='python',如下:

    user = pd.read_table(path1, sep='::', header=None, names=unames, engine='python')

阅读全文>>

标签: python pandas re read_table

评论(0) 浏览(4228)

importError c extension: No module named np_datetine not buit

2018-10-1 杜世伟 Python

我的python代码中有

import pandas

使用pyinstaller进行打包exe的时候出现以下问题,现在就来说一下。
打包的时候没有报错,

但是执行时候首先报了pandas的错。提示没有找到pandas._lilbs.tslibs.np_datetime。大概的错误如下:

第一个错误是:

Fi1e sitepackagesp\pandas\init .py 1ine 35 in Kmodule?

importError c extension: No module named np_datetine not buit. Jf you yant to import pandas from. the source drectory

g you may need to run python setup. py buildext inplace force to bui1d the c extensions first:

iFai1ed to execute script smg



通过网上查找的方法,修改下pyinstaller的用法,生成过程中添加--hiddenimport=pandas._libs.tslibs.np_datetime,代码如下

pyinstaller -F -w smg.py  --hiddenimport=pandas._libs.tslibs.np_datetime

继续打包,过程中没有报错,继续执行exe文件的时候报错如下

第二个错误:
Fi1e sitepackagesp\pandas\init .py 1ine 35 in Kmodule?

Fi1e sitepackagesp\pandas\init .py 1ine 35 in Kmodule?

importError c extension: No module named timedeltas not buit. Jf you yant to import pandas from. the source drectory

g you may need to run python setup. py buildext inplace force to bui1d the c extensions first:

iFai1ed to execute script smg

iFai1ed to execute script smg

阅读全文>>

标签: pandas np_datetime timedeltas

评论(0) 浏览(3025)

四个提高工作效率的小技巧

2018-9-15 杜世伟 Linux

四个提高工作效率的小技巧:
一)有没有那么一个命令,创建目录并切换至新目录下?
在工作中是不是经常使用mkdir创建目录,然后cd到创建的目录下,如果经常这样执行的话是不是特烦,抱怨为什么没有一个现成的命令供使用
纠结中。。。。。
如果这个时候有个方式可以满足你的需求是不是感觉很兴奋,然我们见证实现方式吧:

在当前登录的账号的~/.bash_profile文件中添加如下代码:
function mkdircd () { 
  mkdir -p "$@" && eval cd "\"\$$#\"";
}

然后执行 source ~/.bash_profile 使修改文件生效
这个时候你的服务器下就会有个新的命令,mkdircd

Example:
#mkdircd /tmp/a/b/c
#pwd
/tmp/a/b/c

阅读全文>>

标签: linux cp touch mkdir

评论(0) 浏览(3207)

RuntimeError: Python is not installed as a framework

2018-9-9 杜世伟 Python

今天在mac上,python virtualenv 虚拟环境下运行matplotlib example的时候提示如下报错:
python animation/animated_histogram.py 
Traceback (most recent call last):
  File "animation/animated_histogram.py", line 11, in <module>
    import matplotlib.pyplot as plt
  File "/Users/shiwei/Documents/python_project/study_matplotlib/lib/python3.5/site-packages/matplotlib/pyplot.py", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/Users/shiwei/Documents/python_project/study_matplotlib/lib/python3.5/site-packages/matplotlib/backends/__init__.py", line 62, in pylab_setup
    [backend_name], 0)
  File "/Users/shiwei/Documents/python_project/study_matplotlib/lib/python3.5/site-packages/matplotlib/backends/backend_macosx.py", line 17, in <module>
    from matplotlib.backends import _macosx
RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.

阅读全文>>

标签: python matplotlib RuntimeError

评论(0) 浏览(2769)

valid phone numbers

2018-9-4 杜世伟 awk

Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers.

You may assume that a valid phone number must appear in one of the following two formats: (xxx) xxx-xxxx or xxx-xxx-xxxx. (x means a digit)

You may also assume each line in the text file must not contain leading or trailing white spaces.

Example:

Assume that file.txt has the following content:

987-123-4567
123 456 7890
(123) 456-7890
Your script should output the following valid phone numbers:

987-123-4567
(123) 456-7890

cat > file.txt <<EOF
987-123-4567
(123) 456-7890
0(001) 345-0000
(001) 123-345

阅读全文>>

标签: linux grep awk

评论(0) 浏览(2683)

Elasticsearch史上最全最常用工具清单

2018-6-10 杜世伟 架构

Elasticsearch史上最全最常用工具清单

1、题记
工欲善其事必先利其器,ELK Stack的学习和实战更是如此,特将工作中用到的“高效”工具分享给大家。

希望能借助“工具”提高开发、运维效率!

2、工具分类概览
2.1 基础类工具
1、Head插件

1)功能概述:

ES集群状态查看、索引数据查看、ES DSL实现(增、删、改、查操作)
比较实用的地方:json串的格式化



2)地址:http://mobz.github.io/elasticsearch-head/

2、Kibana工具

除了支持各种数据的可视化之外,最重要的是:支持Dev Tool进行RESTFUL API增删改查操作。
——比Postman工具和curl都方便很多。

阅读全文>>

标签: ansible Elasticsearch elk

评论(0) 浏览(3369)

数据库从0到0.1 : OLTP VS OLAP VS HTAP

2018-5-27 杜世伟 架构

OLTP是Online Transaction Processing的简称;OLAP是OnLine Analytical Processing的简称;HTAP是Hybrid Transactional/Analytical Processing的简称。Transaction是指形成一个逻辑单元,不可分割的一组读,写操作;Online一般指查询延迟在秒级或毫秒级,可以实现交互式查询。

OLTP的查询一般只会访问少量的记录,且大多时候都会利用索引。在线的面向终端用户直接使用的Web应用:金融,博客,评论,电商等系统的查询都是OLTP查询,比如最常见的基于主键的CRUD操作。

OLAP的查询一般需要Scan大量数据,大多时候只访问部分列,聚合的需求(Sum,Count,Max,Min等)会多于明细的需求(查询原始的明细数据)。 OLAP的典型查询一般像:现在各种应用在年末会发布的大数据分析和统计应用,比如2017豆瓣读书报告,2017豆瓣读书榜单,网易云音乐2017听歌报告; OLAP在企业中的一个重要应用就是BI分析,比如2017年最畅销的手机品牌Top5;哪类人群最喜欢小米或华为手机等等。

《Designing-Data-Intensive-Applications》一书指出的OLTP和OLAP的主要区别如下:

OLAP vs OLTP

在CMU-CS 15-415的课程中对OLAP和OLTP这样介绍:

阅读全文>>

标签: oltp olap HTAP

评论(0) 浏览(2856)

"Exit Trap” 让你的 Bash 脚本更稳固可靠

2018-5-14 杜世伟 Linux

有个简单实用的技巧可以让你的 bash 脚本更稳健 -- 确保总是执行必要的收尾工作,哪怕是在发生异常的时候。要做到这一点,秘诀就是 bash 提供的一个叫做 EXIT 的伪信号,你可以 trap 它,当脚本因为任何原因退出时,相应的命令或函数就会执行。我们来看看它是如何工作的。

基本的代码结构看起来像这样:

#!/bin/bash
function finish {
  # 你的收尾代码
}
trap finish EXIT

你可以把任何你觉得务必要运行的代码放在这个 finish 函数里。一个很好的例子是:创建一个临时目录,事后再删除它。

#!/bin/bash
scratch=$(mktemp -d -t tmp.XXXXXXXXXX)
function finish {
  rm -rf "$scratch"
}
trap finish EXIT

这样,在你的核心代码中,你就可以在这个 $scratch 目录里下载、生成、操作中间或临时数据了。注1

阅读全文>>

标签: linux shell trap

评论(0) 浏览(2586)

在 Linux 下 9 个有用的 touch 命令示例

2018-5-2 杜世伟 Linux

touch 命令用于创建空文件,也可以更改 Unix 和 Linux 系统上现有文件时间戳。这里所说的更改时间戳意味着更新文件和目录的访问以及修改时间。

让我们来看看 touch 命令的语法和选项:

语法:

# touch {选项} {文件}
touch 命令中使用的选项:

touch-command-options

touch-command-options

在这篇文章中,我们将介绍 Linux 中 9 个有用的 touch 命令示例。

示例:1 使用 touch 创建一个空文件
要在 Linux 系统上使用 touch 命令创建空文件,键入 touch,然后输入文件名。如下所示:

[root@linuxtechi ~]# touch devops.txt
[root@linuxtechi ~]# ls -l devops.txt
-rw-r--r--. 1 root root 0 Mar 29 22:39 devops.txt

阅读全文>>

标签: linux cat touch stat

评论(0) 浏览(17359)

史上最全Redis高可用技术解决方案大全

2018-4-9 杜世伟 Redis

Redis常见的几种主要使用方式:

  • Redis 单副本

  • Redis 多副本(主从)

  • Redis Sentinel(哨兵)

  • Redis Cluster

  • Redis 自研


Redis各种使用方式的优缺点:

1
Redis单副本

Redis 单副本,采用单个Redis节点部署架构,没有备用节点实时同步数据,不提供数据持久化和备份策略,适用于数据可靠性要求不高的纯缓存业务场景。


优点:

1、架构简单、部署方便

2、高性价比,当缓存使用时无需备用节点(单实例可用性可以用supervisor或crontab保证),当然为了满足业务的高可用性,也可以牺牲一个备用节点,但同时刻只有一个实例对外提供服务。

阅读全文>>

标签: redis sentinel cluster

评论(0) 浏览(2316)

Powered by emlog 沪ICP备2023034538号-1