共 38 篇文章 |
|
In [2]: import matplotlib.pyplot as plt虽然pandas的绘图函数能够处理许多普通的绘图任务,但如果需要自定义一些高级功能的话就必须学习matplotlib API。matplotlib中的Figure还支持一种MATLAB式的编号架构(如plt.figure(2))。由于根据特定布局创建Figure和subplot是一件非常常见的任务,于是便出现了一个更为方便的方法(plt.subplots),... 阅14167 转27 评0 公众公开 16-03-16 15:24 |
描述一个或多个空白符的regex是\s+:view sourceprint?1.In [100]: import re2. 3.In [101]: text = "foo bar\t baz \tqux"4. 5.In [102]: re.split(''\s+'', text)6.Out[102]: [''foo'', ''bar'', ''baz'', ''qux'']调用re.split(''\s+... 阅513 转4 评0 公众公开 16-03-16 15:22 |
view sourceprint?DataFrame({''food'':[''bacon'', ''pulled pork'', ''bacon'', ''Pastrami'', ''corned beef'', ''Bacon'', 02.In [59]: data[np.abs(data) >3] = np.sign(data) * 302.In [81]: genres = sorted(set.... 阅532 转3 评0 公众公开 16-03-16 15:15 |
使用SQLAlchemy.class User(Base): __tablename__ = ''user'' id = Column(String(20), primary_key=True) name = Column(String(20)) # 一对多: books = relationship(''Book'')class Book(Base): __tablename__ = ''book'' id = Column(String(20), primary_key=True) name = Column(String... 阅46 转0 评0 公众公开 16-03-15 21:40 |
read_sql()函数将SQL表读入DataFrame。to_csv()函数将DataFrame数据存储在指定的csv文件中。read_csv()函数将CSV文件中的数据读入DataFrame。1.存储时,CSV和SQL都默认存储行标签(index),因此需要指定存储行标签列的名字,index_label。2.读取时,CSV和SQL都需要指定哪一列是行标签(index)列,index_col,不同的是CSV是通过列的序号指定,... 阅2080 转1 评0 公众公开 16-03-14 21:00 |
DataFrame(np.array([ [''a'', 5, 9], [''b'', 4, 61], [''c'', 24, 9]]), columns=[''name'', ''attr11'', ''attr12''])df2 = pd.DataFrame(np.array([ [''a'', 5, 19], [''b'', 14, 16], [''c... 阅848 转2 评0 公众公开 16-03-09 19:46 |
ACOS Vector Trigonometric ACosASIN Vector Trigonometric ASinATAN Vector Trigonometric ATanCEIL Vector CeilCOS Vector Trigonometric CosCOSH Vector Trigonometric CoshEXP Vector Arithmetic ExpFLOOR Vector FloorLN Vector Log NaturalLOG10 Vector Log10SIN Vector Trigonometric SinSINH Vector Trigonometric SinhSQRT Vector Squ... 阅234 转2 评0 公众公开 16-03-06 10:51 |
当一个新数组用整型数组索引创建时,新数组有相同的形状,而不是整数数组:a = np.array([1, 2, 3, 4])b = np.array([4, 2, 2, 4])c = np.array([1, 2, 3, 4])np.array_equal(a, b)a = np.ones((4, 5))a[0] = 2 # 我们将一个数组的纬度0分配给另一个数组的纬度1a.x = np.linspace(0, 1, 20)y = np.cos(x) + 0.3*np.random.rand(20)p = np.poly1... 阅8804 转5 评0 公众公开 16-02-23 21:51 |
1.4Matplotlib:绘图。import numpy as npX = np.linspace(-np.pi, np.pi, 256, endpoint=True)C, S = np.cos(X), np.sin(X)pl.axes([0, 0, 1, 1])N = 20theta = np.arange(0., 2 * np.pi, 2 * np.pi / N)radii = 10 * np.random.rand(N)width = np.pi / 4 * np.random.rand(N)bars = pl.bar(theta, radii, width=width, bottom=0.0)for r, bar... 阅1317 转3 评0 公众公开 16-02-23 21:48 |
df[''one'']df.one。df.iloc[行位置,列位置]df.iloc[1,1]#选取第二行,第二列的值,返回的为单个值df.iloc[0,2],:]#选取第一行及第三行的数据df.iloc[0:2,:]#选取第一行到第三行(不包含)的数据df.iloc[:,1]#选取所有记录的第一列的值,返回的为一个Seriesdf.iloc[1,:]#选取第一行数据,返回的为一个Series。df.ix[1,1]df.ix[... 阅6079 转30 评0 公众公开 16-02-23 21:42 |