在@post.content,我想要
1.simple_format,所以内容将有不同的行,而不是没有中断的单行
2.html_safe,因此用户可以粘贴一些<embed>视频链接,如youtubes
可以单独使用<%= simple_format @post.content %>和<%= @post.content.html_safe %>单独使用
但是当我一起使用它们时:<%= simple_format @post.content.html_safe %>html_safe不起作用,因此<embed>视频不会显示
你能告诉我如何同时启用<embed>代码simple_format吗?还是有其他解决方案来显示@post.content?谢谢!!!
在我dataframe的时间是3列分隔:year,month,day,就像这样:

我怎样才能将它们转换成date,所以我可以进行时间序列分析?
我可以做这个:
df.apply(lambda x:'%s %s %s' % (x['year'],x['month'], x['day']),axis=1)
Run Code Online (Sandbox Code Playgroud)
这使:
1095 1954 1 1
1096 1954 1 2
1097 1954 1 3
1098 1954 1 4
1099 1954 1 5
1100 1954 1 6
1101 1954 1 7
1102 1954 1 8
1103 1954 1 9
1104 1954 1 10
1105 1954 1 11
1106 1954 1 12
1107 1954 1 13
Run Code Online (Sandbox Code Playgroud)
但接下来呢?
编辑: 这是我最终得到的:
from datetime import datetime …Run Code Online (Sandbox Code Playgroud) 在我看来ipython notebook,有一部分细胞可作为初步检查.
现在我想turn it off,因为在运行之后我知道数据集的状态,但我也想保留它,所以使用这个笔记本的其他人可以拥有这个功能.
我该怎么做?这样做有什么例子吗?
我可以使用comment out这些细胞,但之后切换on并且off会非常费力.对于其他人来说可能不是很有意义.
我可以将它抽象为a function,但它本身有一些方法,所以代码会很复杂,可能很难读懂?

上面的图片就是我的意思.我认为代码应该是这样的:
<% @days_from_this_week.each do |day| %>
<%= day.name %>
<!--e.g. Monday-->
<% day.sessions do |session| %>
<% @session_categories.each do |category| %>
<!--categories means the Sesion1/2/3/4 category
A day's sessionX could be empty, so we have to determine wheather a session matches its cateogry,
and then display it in the table
-->
<% if session.category == category %>
<%= session.content %>
<% end %>
<% end %>
<% end %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
但是如何获得current week?以及如何获得name of a day …
版本控制.dwg真的是一个问题.我想知道是否有可能git用来控制版本?或者只是在文件中提交我的更改?
如果这是不可能的,那么什么是版本控制的好方法.dwg?
我发现:当项目树有二进制文件时,GIT,Mercurial,SVN或其他版本控制工具能否正常工作?
它说svn合作cad,它现在是唯一的解决方案吗?
我的笔记本有点长,我把它分成几个部分.有时,我只是想运行它的某个部分,即consecutive cells
我想跑Cell IN [52] to[54],不跑IN [51],[59].我该怎么做?
我只知道有选项run above,run below我没有看见像什么run selected cells.
更新:现在Jupyter Notebook内置了这个功能,只需按CTRL +单击即可
这可能是一个字符串
ipath= "./data/NCDC/??/??/9705626661750dat.txt"
Run Code Online (Sandbox Code Playgroud)
或这个
ipath = './data/NCDC/ciampino/6240476818161dat.txt'
Run Code Online (Sandbox Code Playgroud)
我怎么知道第一个字符串包含中文?
我发现这个答案可能有用: 使用Python和Regex查找字符串中的所有中文文本
但它没有成功:
import re
ipath= "./data/NCDC/??/??/9705626661750dat.txt"
re.findall(ur'[\u4e00-\u9fff]+', ipath) # => []
Run Code Online (Sandbox Code Playgroud) 我有一个包含属性x,y的数据集,它们可以在xy表面绘制.
最初,我使用代码
df.plot(kind='scatter', x='x', y='y', alpha=0.10, s=2)
plt.gca().set_aspect('equal')
Run Code Online (Sandbox Code Playgroud)
代码非常快,数据大小约为50000.
最近,我使用了一个新的数据集,大小约为250万.散点图变得慢得多.
我想知道,如果这是预期的行为,我是否可以采取任何措施来提高情节速度?
我想知道如何df.describe()与df.summary()实现
def summary(self, *statistics):
if len(statistics) == 1 and isinstance(statistics[0], list):
statistics = statistics[0]
jdf = self._jdf.summary(self._jseq(statistics))
return DataFrame(jdf, self.sql_ctx)
Run Code Online (Sandbox Code Playgroud)
我对python中的OO不是很熟悉,我有点困惑。分位数和其他统计数据在哪里实施?
在我Ipython Notebook,我有一个脚本生成一系列多个数字,如下所示:

问题是,这些数字take too much space,我正在产生许多这些组合.这使我很难在这些数字之间导航.
我想在同一行中制作一些情节.我该怎么做?
更新:
感谢fjarri的建议,我已经更改了代码,这适用于绘制在同一行.
现在,我想让它们以不同的方式绘制(默认选项).我该怎么办?我尝试了一些,但不确定这是否正确.
def custom_plot1(ax = None):
if ax is None:
fig, ax = plt.subplots()
x1 = np.linspace(0.0, 5.0)
y1 = np.cos(2 * np.pi * x1) * np.exp(-x1)
ax.plot(x1, y1, 'ko-')
ax.set_xlabel('time (s)')
ax.set_ylabel('Damped oscillation')
def custom_plot2(ax = None):
if ax is None:
fig, ax = plt.subplots()
x2 = np.linspace(0.0, 2.0)
y2 = np.cos(2 * np.pi * x2)
ax.plot(x2, y2, 'r.-')
ax.set_xlabel('time (s)')
ax.set_ylabel('Undamped')
# 1. Plot in same …Run Code Online (Sandbox Code Playgroud)