自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(34)
  • 收藏
  • 关注

原创 linux学习01

### repeat commandshistory :: 打印命令行历史!6 :: 重新运行命令历史的第6条命令head -n 5 seasonal/summer.csv::打印seasonal/summer.csv前5行

2019-06-24 19:31:27 143

转载 Performing HTTP requests in Python using urllib

Performing HTTP requests in Python using urllib# Import packagesfrom urllib.request import urlopen, Request# Specify the urlurl = "http://www.datacamp.com/teach/documentation"# This packages th...

2019-05-27 22:16:23 177

转载 Importing data from the Internet

# Import packagefrom urllib.request import urlretrieve# Import pandasimport pandas as pd# Assign url of file: urlurl = 'https://s3.amazonaws.com/assets.datacamp.com/production/course_1606/datas...

2019-05-27 20:52:20 269

转载 sql

Querying relational databases in Python# Import necessary modulefrom sqlalchemy import create_engine# Create engine: engineengine = create_engine('sqlite:///Chinook.sqlite')# Save the table nam...

2019-05-26 22:46:18 198

翻译 Importing Data in Python: Importing data from other file types

import oswd = os.getcwd()os.listdir(wd)## loading a pickle file# Import pickle packageimport pickle# Open pickle file and load data: dwith open('data.pkl', 'rb') as file: d = pickle.load(...

2019-05-26 14:55:12 245

翻译 Importing data in python: Introducton and flat fils

1. Introduction and flat files1.1 importing entire text files# Open a file: filefile = open('moby_dick.txt', mode = 'r')# Print itprint(file.read())# Check whether file is closed using closed...

2019-05-26 13:19:52 265

翻译 advanve comprehesions

list comprehensions# Create a 5 x 5 matrix using a list of lists: matrixmatrix = [[col for col in range(5)] for row in range(5)]# Print the matrixfor row in matrix: print(row)[0, 1, 2, 3, ...

2019-05-24 22:10:54 181

转载 enumerate and zip

enumerate() returns an enumerate object that produces a sequence of tuples, and each of the tuples is an index-value pair.# Create a list of strings: mutantsmutants = ['charles xavier', ...

2019-05-24 21:31:03 347

翻译 Introduction to iterators

2019-05-24 19:56:52 145

翻译 error handing

# Define shout_echodef shout_echo(word1, echo=1): """Concatenate echo copies of word1 and three exclamation marks at the end of the string.""" # Initialize empty strings: echo_word, shou...

2019-05-23 21:34:42 349

翻译 default and flexable arguments

Functions with one default argument# Define shout_echodef shout_echo(word1, echo = 1): """Concatenate echo copies of word1 and three exclamation marks at the end of the string.""" # Co...

2019-05-23 20:50:01 147

原创 查看python内置范围

import builtinsdir(builtins)

2019-05-23 20:00:19 166

翻译 using tuples to return multiple values

# Define shout_all with parameters word1 and word2def shout_all(word1, word2): # Concatenate word1 with '!!!': shout1 shout1 = word1 + '!!!' # Concatenate word2 with '!!!': shou...

2019-05-23 19:26:55 214

翻译 random walk

# Numpy is imported, seed is setimport numpy as npnp.random.seed(123)# Initialize random_walkrandom_walk = [0]# Complete the ___for x in range(100) : # Set step: last element in random_walk...

2019-05-22 22:35:12 1152

翻译 random module

seed(): sets the random seed, so that your results are the reproducible between simulations. As an argument, it takes an integer of your choosing. If you call the function, no output will be genera...

2019-05-22 21:27:55 145

翻译 数组比较

# Create arraysimport numpy as npmy_house = np.array([18.0, 20.0, 10.75, 9.50])your_house = np.array([14.0, 24.0, 14.25, 9.0])# my_house greater than 18.5 or smaller than 10print(np.logical_or(m...

2019-05-21 23:18:12 406

翻译 pndas DataFrame

import pandas as pd# Build cars DataFramenames = ['United States', 'Australia', 'Japan', 'India', 'Russia', 'Morocco', 'Egypt']dr = [True, False, False, False, True, True, True]cpc = [809, 731, 5...

2019-05-21 21:59:47 254

翻译 dict

# Definition of dictionaryeurope = {'spain':'madrid', 'france':'paris', 'germany':'berlin', 'norway':'oslo' }# Print out the keys in europeprint(europe.keys())# Print out value that belongs to key...

2019-05-20 23:25:46 173

翻译 matplotlib

# line plotimport matplotlib.pyplot as pltplt.plot(x,y)plt.show()# Import packageimport matplotlib.pyplot as plt# scatter plotplt.scatter(x,y)# Put the x-axis on a logarithmic scaleplt.xscal...

2019-05-20 23:07:04 265

转载 Numpy

2019-05-20 19:37:36 140

转载 list

The ; sign is used to place commands on the same line. The following two code chunks are equivalent:# Same linecommand1; command2# Separate linescommand1command2help(). In IPython specif...

2019-05-19 23:05:18 138

原创 python字符串

print('dataquest'.startswith('Data')) # Falseprint('dataquest'.startswith('data')) # Trueprint('dataquest'.upper().startswith('DATA')) # True

2019-05-18 23:48:44 142

原创 Jupyter Notebook

%history -p # 查看历史记录openfile = open(r'C:\Users\cheng\Desktop\test.txt') # 读取文件

2019-05-18 19:25:22 164

转载 python datetime模块日期与时间的处理

Python has three standard modules that are designed to help working with dates and times:The calendar moduleThe time moduleThe datetime moduleimport datetime as dtibm_founded = dt.datetime(1911...

2019-05-18 19:06:42 731

原创 函数式编程工具:map, filter和reduce

1. map将一个函数映射到一个输入列表的所有元素上map(function_to_apply, list_of_inputs) # 结构list(map((lambda x: x + 3), [1, 2, 3, 4])) # [4, 5, 6, 7]list(map(pow, [1, 2, 3], [2, 3, 4])) # 1 ** 2, 2 ** 3, 3 ** 42. filt...

2019-05-18 00:59:05 251

转载 列表解析

列表解析结构[expression for target1 in iterable1 [if condition1] for target2 in iterable2 [if condition2]... for targetN in iterableN [if conditionN]]例如res = []for x in range(5): if x % 2 == ...

2019-05-18 00:20:58 325

转载 import导入的几种方式

1. Import the whole module by name2. Import definitions via name or wildcard3.Import whole module by alias

2019-05-17 23:48:59 2084

原创 读取csv文件转换为列表序列

from csv import readerpotus = list(reader(open(‘potus_visitors_2015.csv’)))

2019-05-17 21:51:09 4550 2

转载 Class

An object is an entity that stores data.An object’s class defines specific properties objects of that class will have.

2019-05-16 22:07:52 130

转载 apply formatting to numbers using str.format()

![在这里插入图片描述](file:///C:/Users/cheng/Desktop/str_format_v2_1_1.svg)

2019-05-16 21:11:14 267

转载 str.format() method

字符串输出name = "Kylie"num = 8output = name + "'s favorite number is " + str(num)print(output)Kylie’s favorite number is 8str.format() method 输出1. The variables are inserted into the {} by the or...

2019-05-16 20:45:17 240

转载 frequence table

fruit = ['orange', 'orange', 'orange', 'banana', 'apple', 'banana', 'orange', 'banana', 'apple', 'banana'] fruit_frequency = {}for f in fruit: if f not in fruit_freque...

2019-05-16 20:31:08 211

转载 Count the number of Duplicates

Count the number of DuplicatesWrite a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The inpu...

2019-04-26 22:50:56 365

原创 命令行中运行编辑好的python代码

命令行中运行编辑好的python代码完整目录相对目录完整目录相对目录

2019-03-31 19:57:50 522

空空如也

空空如也

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

TA关注的人

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