小编Had*_*san的帖子

如何更改运行函数的单元格的格式

如果我有以下用户定义的函数,我可以返回文本“foo”...

function myFunction(input){
   return "You wrote: "+ input;
}
Run Code Online (Sandbox Code Playgroud)

如何通过代码为单元格指定红色背景?尽管这是一个简单的示例,但我的脚本更复杂,我想通过代码分配格式(我不想使用“格式”>“条件格式...”选项;我需要在单个脚本中配置所有内容。

这里面有什么可以发挥作用的吗?

function myFunction(input){
   setBackground('red');
   return "You wrote: "+ input;
}
Run Code Online (Sandbox Code Playgroud)

getActiveCell对我不起作用,因为这会触发单击(或激活)的单元格,而不一定是包含公式的单元格。

google-sheets google-apps-script google-sheets-custom-function

4
推荐指数
1
解决办法
3590
查看次数

Excel 的 SUMIF 函数的 Python 列表或 NumPy 等价物是什么?

我有一个二维数组:

expenses = np.array([['jim', 'sam', 'bill', 'sam'],[1,2,6,5]])
Run Code Online (Sandbox Code Playgroud)

我想知道新数组中每个唯一人员的总费用,而不需要对任何名称进行硬编码(实际列表很长),以便得到如下输出:

totals = [['jim', 'sam', 'bill'],[1,7,6]]
Run Code Online (Sandbox Code Playgroud)

有没有办法用列表或 NumPy 来做到这一点?我不想为此使用 Pandas。

提前致谢!

python arrays numpy list

2
推荐指数
1
解决办法
4302
查看次数