自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(44)
  • 资源 (2)
  • 收藏
  • 关注

原创 pingIP告警

当我们需要调用系统的命令的时候,最先考虑的os模块。用os.system()和os.popen()来进行操作。但是这两个命令过于简单,不能完成一些复杂的操作,如给运行的命令提供输入或者读取命令的输出,判断该命令的运行状态,管理多个命令的并行等等。这时subprocess中的Popen命令就能有效的完成我们需要的操作。import winsoundimport subprocessmp3 =

2015-10-10 12:40:05 801

原创 pandas移动窗口计算脉动

import osimport pandas as pdimport numpy as np#每个文件只取前三行后生成的maidong_filesroot = 'D:/maidong_files'all_U = pd.DataFrame()all_V = pd.DataFrame()all_chuizhi = pd.DataFrame()all_time = []#定义计算函数,用到数组

2015-08-02 22:59:34 1453

原创 pandas groupby (TimeGrouper)重写Q3

import osimport pandas as pdimport datetimeroot = 'D:/select_files'all_sudu = pd.DataFrame()all_time = []for every_file in os.listdir(root):#每个文件取一列 df=pd.read_csv(os.path.join(root,every_file),

2015-08-01 21:44:12 2492

原创 生成测试数据

import osimport pandas as pdimport randomroot = r'D:\R\P'output_path = 'D:/select_files'file_list = []for every_file in os.listdir(root): #print every_file file_list.append(every_file)#随机

2015-08-01 16:52:04 527

转载 pandas time series/data functionality

# 72 hours starting with midnight Jan 1st, 2011In [1]: rng = date_range(’1/1/2011’, periods=72, freq=’H’)In [3]: ts = Series(randn(len(rng)), index=rng)In [4]: ts.head()Out[4]:2011-01-01 00:00:00

2015-07-31 08:43:20 652

转载 pandas RESHAPING AND PIVOT TABLES

In [1]: dfOut[1]: date variable value0 2000-01-03 A 0.4691121 2000-01-04 A -0.2828632 2000-01-05 A -1.5090593 2000-01-03 B -1.1356324 2000-01-04 B 1.2121125 2000-01-05 B -0.1732156 2000-01

2015-07-30 12:15:01 521

转载 pandas merge,join and concatenate

Concatenating objectsIn [3]: pieces = [df[:3], df[3:7], df[7:]]In [4]: concatenated = concat(pieces)In [5]: concatenatedOut[5]: 0 1 2 30 0.469112 -0.282863 -1.509059 -1.135

2015-07-30 08:18:12 1199

转载 python 逻辑表达式应用

抓了a,b,c,d4名犯罪嫌疑人.其中有一名是小偷,审讯中: a说我不是小偷 b说c是小偷 c说小偷肯定是d d说c胡说! 其中有3个人说的是实话,一个人说的是假话,编程推断谁是小偷。 (用穷举法和逻辑表达式)for xiaotou in ['a','b','c','d']: sum = (xiaotou != 'a

2015-07-29 17:37:21 1029

转载 Rolling mean with customized window with Pandas

data = pd.Series(range(1, 9))data_mean = pd.rolling_mean(data, window=5).shift(-2)print(data_mean)0 NaN1 NaN2 33 44 55 66 NaN7 NaNdtype: float64

2015-07-29 16:15:45 1373

转载 pandas group by

GroupBy with MultiIndexIn [24]: sOut[24]: first secondbar one -0.575247 two 0.254161baz one -1.143704 two 0.215897foo one 1.193555 two -0.077118qux one -0.408530 two -0.862495

2015-07-29 16:07:00 5729

原创 pandas working with missing data

In [1]: df = DataFrame(randn(5, 3), index=[’a’, ’c’, ’e’, ’f’, ’h’],...: columns=[’one’, ’two’, ’three’])In [2]: df[’four’] = ’bar’In [3]: df[’five’] = df[’one’] > 0In [4]: dfOut[4]: one t

2015-07-29 09:00:22 361

原创 pandas multiIndex

In [1]: arrays = [[’bar’, ’bar’, ’baz’, ’baz’, ’foo’, ’foo’, ’qux’, ’qux’],...: [’one’, ’two’, ’one’, ’two’, ’one’, ’two’, ’one’, ’two’]]In [2]: tuples = list(zip(*arrays))In [4]: index = MultiIndex

2015-07-26 08:54:38 2161

原创 pandas indexing and slicing data

`In [9]: dfOut[9]: A B C D2000-01-01 0.469112 -0.282863 -1.509059 -1.1356322000-01-02 1.212112 -0.173215 0.119209 -1.0442362000-01-03 -0.861849 -2.104569 -0.494929

2015-07-25 18:47:43 580

原创 pandas options and settings

pd.set_option(’precision’, 5)`In [46]: pd.set_option(’max_colwidth’, 6)In [47]: dfOut[47]: 0 1 2 30 foo bar bim un...1 horse cow ba... appleIn [55]: df=pd.DataFrame(np.random.choice

2015-07-24 17:13:45 401

原创 pandas working with text data

In [13]: dollars = Series([’12’, ’-$10’, ’$10,000’])# This does what you’d naively expect:In [14]: dollars.str.replace(’$’, ’’)Out[14]:0 121 -102 10,000dtype: objectIn [22]: Series([’a1’, ’b2’,

2015-07-23 07:21:29 408

原创 pandas essential functions

In [8]: df[:2]Out[8]:A B C2000-01-01 0.187483 -1.933946 0.3773122000-01-02 0.734122 2.141616 -0.011225In [9]: df.columns = [x.lower() for x in df.columns]In [10]: dfOut[10]: a

2015-07-23 07:11:16 363

原创 测试网络连通

简单测试局域网中的电脑是否连通.这些电脑的ip范围从192.168.0.101到192.168.0.200. import subprocesscmd="cmd.exe"begin=101end=200while begin<end: p= subprocess.Popen(cmd,shell=True,stdout=subprocess

2015-07-21 17:44:29 392

原创 pandas常用操作

In [6]: dates = pd.date_range(’20130101’,periods=6)In [8]: df = pd.DataFrame(np.random.randn(6,4),index=dates,columns=list(’ABCD’))In [9]: dfOut[9]: A B C D

2015-07-20 21:01:02 1811

原创 发送邮件

发送文本import smtplib from email.mime.text import MIMEText mailto_list=[' '] mail_host="smtp.163.com" #设置服务器mail_user=" " #用户名mail_pass=" " #口令 mail_postfix="163.com" #发件箱的后缀def send_mail(t

2015-07-19 10:59:20 502

原创 查询外网址

import timeif __name__=='__main__': flag=True while flag : execfile('ScratchIP.py') print 'ok...' time.sleep(10)ScratchIP.pyimport urllib2, reimport timeur

2015-07-19 10:39:27 273

原创 os模块

os.path.abspath(path) 返回path规范化的绝对路径。>>> os.path.abspath('test.csv')'C:\\Python25\\test.csv'>>> os.path.abspath('c:\\test.csv')'c:\\test.csv'>>> os.path.abspath('../csv\\test.csv')'C:\\csv\\test.

2015-07-19 10:14:44 213

原创 pip安装包

下载pip-X.X.tar.gz cd pip-x.x python setup.py install 通过pip来安装django pip install django pip uninstall django pip install –upgrade SomePackage pip install SomePackage==1.0.4 pip install ./download

2015-07-19 09:50:24 296

原创 Linux常用操作

打开ubuntu 上的telnet 服务 sudo apt-get install telnetd 再重启ubuntu如何下载软件 打开终端,sudo apt-get install 软件名 apt-get remove #—–(package 删除包) apt-get autoremove –purge # —-(package 删除包及其依赖的软件包+配置文件等Ubuntu中查看已安装

2015-07-19 09:08:01 223

原创 Core Python

Tuples A tuple is a sequence of arbitrary objects separated by commas and enclosed in parentheses. If the tuple contains a single object, the parentheses may be omitted. Tuples support the same operat

2015-07-19 08:35:56 434

原创 类的应用

class Y: def __init__(self, v0): self.v0 = v0 self.g = 9.81 def value(self, t): return self.v0*t - 0.5*self.g*t**2y = Y(3)v = y.value(0.1)more examples on classes: Ban

2015-07-18 20:34:04 329

原创 pandas重写Q6

# -*- coding: utf-8 -*-"""Created on Mon Jul 13 19:17:05 2015@author: Administrator"""import pandas as pdimport numpy as npimport osInputDir = r'D:\R\P'rootdir = InputDirpieces = []heightIndex

2015-07-14 06:49:32 1120

原创 pandas重写Q5

# -*- coding: utf-8 -*-"""Created on Mon Jul 13 19:17:05 2015@author: Administrator"""import pandas as pdimport numpy as npimport osInputDir = r'D:\R\P'rootdir = InputDirpieces = []for parent,di

2015-07-13 20:38:50 823

原创 pandas重写Q4

# -*- coding: utf-8 -*-"""Created on Thu Jul 09 20:31:38 2015@author: Administrator"""import pandas as pdimport numpy as npimport osInputDir = r'D:\R\P'rootdir = InputDirpieces = []for parent,dirn

2015-07-13 19:10:27 466

原创 pandas groupby重写Q3

-- coding: utf-8 --“”” Created on Thu Jul 09 20:31:38 2015@author: Administrator “”“import pandas as pd import numpy as np import osInputDir = r’D:\R\P’rootdir = InputDirpieces = []for parent,dirna

2015-07-09 22:17:34 536

原创 Ipython

df = pd.DataFrame(np.array([[1,2,3],[4,5,6],[7,8,9]]))Ipython平台上先小数据试验,对于科学计算来说非常便捷迅速

2015-07-05 17:46:28 238

原创 pandas重写Q3

## -*- coding: utf-8 -*-import numpy as npimport pandas as pd from numpy.matlib import repmatfilepathofU = r'C:\Users\Administrator\Desktop\weixiang.txt'filepathofV = r'C:\Users\Administrator\Deskt

2015-07-05 17:31:49 601

原创 python时间操作

str = 'Z_RADA_I_57793_20130628000000_P_WPRD_LC_ROBS.txt'str.split('_')Out[2]: ['Z', 'RADA', 'I', '57793', '20130628000000', 'P', 'WPRD', 'LC', 'ROBS.txt']getTime = str.split('_')[4]In [4]: getTime

2015-07-05 13:40:59 308

原创 pandas+numpy ufunc重写question2计算位温

# -*- coding: utf-8 -*-"""Created on Fri Jul 03 14:15:43 2015@author: wawatou83"""import pandas as pdimport numpy as npimport osInputDir = r'D:\R\P'rootdir = InputDir#初始化速度和角度以高度层suduDfInitial=p

2015-07-05 09:49:25 915

原创 使用python和numpy重写计算uv分量脚本

# -*- coding: utf-8 -*-"""Created on Fri Jul 03 14:15:43 2015@author: wawatou83"""import pandas as pdimport numpy as npimport osInputDir = r'D:\R\P'rootdir = InputDir#初始化U、V、W以高度层weixiangDfIniti

2015-07-04 20:59:10 1189

原创 US Baby Names 1880-2010

US Baby Names 1880-2010 There are many things you might want to do with the data set: • Visualize the proportion of babies given a particular name (your own, or another name) over time. • Determine

2015-07-03 06:50:34 948

原创 python for data analysis 操作usagov_bitly_data示例

python for data analysis 操作usagov_bitly_data示例import jsonpath = 'ch02/usagov_bitly_data2012-03-16-1331923249.txt'records = [json.loads(line) for line in open(path)]In [18]: records[0]Out[18]:{u'a'

2015-07-02 20:12:31 2629 1

原创 Spyder常用环境working directory设置

Spyder常用环境working directory设置 1.Spyder change working directory and then set as current console’s working directory 2.或者敲命令:%cd directory。注意windows写路径是’\’,而非windows写路径是’/’。 3.查看当前的working directory,

2015-07-02 19:24:50 5143

原创 pandas擅长数据I/O处理numpy擅长数组数值计算

coordinates = df.as_matrix(columns=['lon', 'lat'])pandas读取写入I/O之后可以转化为numpy来计算处理

2015-03-14 19:48:35 551

原创 pandas遍历文件夹提取单个文件中的部分列集合

import pandas as pdimport numpy as npimport osInputDir = r'D:\workfile\juanworkfile\R\P'rootdir = InputDirsududfInitialWithHeight=pd.read_csv(r'D:\workfile\juanworkfile\R\P\Z_RADA_I_57793_20130628000

2015-03-14 14:31:26 4586

原创 pandas读取txt返回有记录数据的最高高度

import pandas as pdimport numpy as np#skiprows跳过行数#nrows指定读取行数#sep指定分隔符df=pd.read_csv('Z_RADA_I_57793_20130628000000_P_WPRD_LC_ROBS.TXT',skiprows=3,header=None,nrows=99,sep=' ')#先用制式np.nan替代缺测值'//

2015-03-02 17:37:04 2665

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除