我有以下时间序列:
Date Value
0 2006-01-03 18
1 2006-01-04 12
2 2006-01-05 11
3 2006-01-06 10
4 2006-01-09 22
... ... ...
3510 2019-12-23 47
3511 2019-12-24 46
3512 2019-12-26 35
3513 2019-12-27 35
3514 2019-12-30 28
Run Code Online (Sandbox Code Playgroud)
我想计算每月的平均值。所以每个月的伪代码如下:
所需的输出类似于:
Date Value
0 2006-01 17.45
1 2006-02 18.23
2 2006-04 16.79
3 2006-05 17.98
... ... ...
166 2019-11 37.89
167 2019-12 36.34
Run Code Online (Sandbox Code Playgroud)
我尝试过这个但没有成功:
data = data.set_index('Date')
data.resample('M')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-28-435afe449f1f> in <module>
47 data …
Run Code Online (Sandbox Code Playgroud) 我按照这篇博文安装了以下任务来编译我的 Go 项目:https://robertbasic.com/blog/build-and-run-golang-projects-in-vs-code/
任务.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build Go",
"type": "shell",
"command": "go build",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
现在我可以使用“终端”>“运行构建任务”来编译项目
为了运行和调试,我创建了:
启动.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": …
Run Code Online (Sandbox Code Playgroud) 我已经读过Julia拥有Macros,但是我不确定Julia提供的Macros是否是我正在考虑的宏。
我有以下表达:
Global.data[
Dates.value(Dates.Year(dtCursor)) - 2000,
Dates.value(Dates.Month(dtCursor)),
Dates.value(Dates.Day(dtCursor)),
Dates.value(Dates.Hour(dtCursor)) + 1,
Dates.value(Dates.Minute(dtCursor)) + 1,
1
]
Run Code Online (Sandbox Code Playgroud)
我会重复很多次。我想知道是否可以使用dtCursor作为参数的宏(在其他情况下可能是其他变量)为我键入所有内容。因此,我正在寻找通常在宏汇编程序中找到的宏扩展功能。
我绝对不想将此作为函数包含在内,因为此代码已执行了成千上万次,因此,我不想增加函数调用的开销。
我试过了:
macro readData(_dtCursor, value)
return :(
Global.data[
Dates.value(Dates.Year(_dtCursor)) - 2000,
Dates.value(Dates.Month(_dtCursor)),
Dates.value(Dates.Day(_dtCursor)),
Dates.value(Dates.Hour(_dtCursor)) + 1,
Dates.value(Dates.Minute(_dtCursor)) + 1,
value
]
)
end
Run Code Online (Sandbox Code Playgroud)
后来被调用:
println(@readData(dtCursor, 1))
Run Code Online (Sandbox Code Playgroud)
dtCursor
DateTime变量在哪里。
但我得到:
ERROR: LoadError: UndefVarError: _dtCursor not defined
Run Code Online (Sandbox Code Playgroud)
我已经阅读了https://docs.julialang.org/en/v1/manual/metaprogramming/index.html#man-macros-1,但是真的很乐于帮助您理解这种情况下的处理方法。
我想转这个:
mystr = ' foo1 (foo2 foo3 (foo4))'
Run Code Online (Sandbox Code Playgroud)
进入:
['foo1','foo2 foo3 (foo4)']
Run Code Online (Sandbox Code Playgroud)
所以基本上我必须根据一些空格/制表符和括号进行拆分。
我已经看到 re package split 函数可以处理多个分隔符(Python: Split string with multiple delimiters),但我无法理解解析这种字符串的正确方法。
哪个是最好的-最pythonic-和简单的方法?
如果新的Odoo模块需要给定的Python包,是否需要或建议在manifest .py中包含该依赖项作为外部依赖?
如果是这样,具体包括该参考?
对于此 XML 摘录,我想指定“最后一个内部组”,在本例中为“报告”,但该内部区域可能有更多标签,我想要“其他信息”中的最后一个
那么我怎么能说“最后一组页面string='Other Information'
”呢?
<page string="Other Information">
<group>
<group string="Sales Information" name="sales_person">
<field name="user_id"/>
<field name="team_id" options="{'no_create': True}"/>
<field name="client_order_ref"/>
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
<field name="project_id" attrs="{'invisible':[('state','=','sale')]}" context="{'default_partner_id':partner_invoice_id, 'default_name':name}" groups="analytic.group_analytic_accounting"/>
<field name="related_project_id" attrs="{'readonly': ['|',('project_id','!=',False),('invoice_count','!=',0),('state','=','sale')],'invisible':[('state','!=','sale')]}" context="{'default_partner_id':partner_invoice_id, 'default_name':name}" groups="analytic.group_analytic_accounting"/>
</group>
<group name="sale_pay" string="Invoicing">
<field name="fiscal_position_id" options="{'no_create': True}"/>
<field name="invoice_status" attrs="{'invisible': [('state', 'not in', ('sale','done'))]}"/>
</group>
<!-- ***** THIS ONE ****** -->
<group string="Reporting" name="technical" groups="base.group_no_one">
<field groups="base.group_no_one" name="origin"/>
</group>
<!-- ***** THIS ONE ****** -->
</group>
</page>
Run Code Online (Sandbox Code Playgroud) 我正在定义我自己的report.paperformat
。我正在尝试不同的网络配置margin_top
,但header_space
我无法理解每个参数的作用。
margin_top
当和中使用给定值时header_space
, 所使用的单位是什么wlkhtmltopdf
?15
in的值和in 中使用margin_top
的值是什么意思?5
header_line
我stock.picking
使用一个新方法扩展了模型,该方法do_new_transfer_xmlrpc
启用了XMLRPC的基本new_transfer.
class Picking(models.Model):
_inherit = 'stock.picking'
@api.multi
def do_new_transfer_xmlrpc(self):
print 'DEBUG'
self.do_transfer()
return ['OK', '']
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下方法调用该方法:
api.execute_kw(db, uid, pwd, 'stock.picking', 'do_new_transfer_xmlrpc', [[int(picking_id)], {}])
Run Code Online (Sandbox Code Playgroud)
但我得到:
Fault: <Fault 1: 'Traceback (most recent call last):\n File "/usr/lib/python2.7/dist-packages/odoo/service/wsgi_server.py", line 56, in xmlrpc_return\n result = odoo.http.dispatch_rpc(service, method, params)\n File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 118, in dispatch_rpc\n result = dispatch(method, params)\n File "/usr/lib/python2.7/dist-packages/odoo/service/model.py", line 38, in dispatch\n res = fn(db, uid, *params)\n File "/usr/lib/python2.7/dist-packages/odoo/service/model.py", line 157, in execute_kw\n return execute(db, uid, obj, method, *args, …
Run Code Online (Sandbox Code Playgroud) 我有一个 html<span>
标签,其中包含类似于以下内容的文本:
Example 1:
FOO/BAR/FOO9/10/FOO2 BAR2/FOO3BAR3
Example 2:
FOO/BAR/FOO9/10/FOO4\BAR4/FOO3BAR3/FOO5/BAR5
Run Code Online (Sandbox Code Playgroud)
它用于移动环境,因此空间有限。
当字符串包含空格时,该字符串将被分成两行,但有些字符串(见示例 2)缺少任何空格并且它们在移动设备中没有完全显示。
所有字符串都/
用于分隔每个单词。无论如何,是否可以使用/
与 html 相同的空格来允许中断字符串。
我正在使用引导程序 3,不确定这是否相关。
我有以下 PythonDecimal
变量:
mydecimal = Decimal('1.452300')
Run Code Online (Sandbox Code Playgroud)
以及以下分辨率变量:
resolution = Decimal('0.0001')
Run Code Online (Sandbox Code Playgroud)
如何resolution
仅使用这两个变量(这是我在实际例程中将拥有的信息)将变量截断为值:
# Desired result:
truncated_mydecimal = Decimal('1.4523') # <-- How do I get this using 'resolution' and 'mydecimal' ?
Run Code Online (Sandbox Code Playgroud)