我有一本字典如下:
my_keys = {'a':10, 'b':3, 'c':23}
Run Code Online (Sandbox Code Playgroud)
我把它变成一个数据框:
df = pd.DataFrame.from_dict(my_keys)
Run Code Online (Sandbox Code Playgroud)
它输出df如下
a b c
0 10 3 23
Run Code Online (Sandbox Code Playgroud)
我怎样才能让它看起来像下面这样:
Col1 Col2
a 10
b 3
c 23
Run Code Online (Sandbox Code Playgroud)
我已经尝试过 orient=index 但仍然无法获取列名?
我的HTML:
<select id='select-id' v-model='position'>
<option>Opt 1</option>
<option>Opt 1</option>
</select>
Run Code Online (Sandbox Code Playgroud)
Vue组件:
var app = new Vue({
el: '#elementid',
data: {
name: '',
position: 'Select Option',
},
});
Run Code Online (Sandbox Code Playgroud)
当他们选择一个选项时,我正在使用v-model将该值发送到数据变量“名称”(将用于其他用途)。
但是,在外观上,选择框是空白的,直到我打开它并选择一个选项。如果删除了v模型,它可以像往常一样工作,并且可以将选项1作为预选选项。我什至尝试将“名称”预设为“选择选项”。我尝试使用html5“选定的已禁用”属性。
我已经将一大堆 PDF 文档转换为文本,然后将它们编译为字典,我知道我有 3 种不同的文档类型,我想使用聚类来自动对它们进行分组:
dict_of_docs = {'document_1':'contents of document', 'document_2':'contents of document', 'document_3':'contents of document',...'document_100':'contents of document'}
Run Code Online (Sandbox Code Playgroud)
然后,我对字典的值进行了向量化:
vectorizer = TfidfVectorizer(stop_words='english')
X = vectorizer.fit_transform(dict_of_docs.values())
Run Code Online (Sandbox Code Playgroud)
我的 X 输出是这样的:
(0, 768) 0.05895270500636258
(0, 121) 0.11790541001272516
(0, 1080) 0.05895270500636258
(0, 87) 0.2114378682212116
(0, 1458) 0.1195944498355368
(0, 683) 0.0797296332236912
(0, 1321) 0.12603709835806634
(0, 630) 0.12603709835806634
(0, 49) 0.12603709835806634
(0, 750) 0.12603709835806634
(0, 1749) 0.10626171032944469
(0, 478) 0.12603709835806634
(0, 1632) 0.14983692373373858
(0, 177) 0.12603709835806634
(0, 653) 0.0497440271723707
(0, 1268) 0.13342186854440274
(0, 1489) 0.07052056544031632
(0, …Run Code Online (Sandbox Code Playgroud) 我是 bash 新手,我的任务是删除所有 30 天以上的文件,我可以根据文件名来解决这个问题Y_M_D.ext 2019_04_30.txt。
我知道我可以列出包含文件ls的文件夹中的所有文件。我知道我可以获得今天的日期,$ date并且可以配置它以匹配文件格式$ date "+%Y_%m_%d"
我知道我可以使用rm.
我如何将所有这些结合到一个 bash 脚本中,该脚本删除从今天起 30 天之前的文件?
在伪 python 代码中,我想它看起来像:
for file in folder:
if file.name to date > 30 day from now:
delete file
Run Code Online (Sandbox Code Playgroud) 我的协调器接收一个有效负载,该有效负载包含需要与其他数据集一起传递给活动函数的指令。
如何将多个参数传递给活动函数?还是我必须将所有数据混合在一起?
def orchestrator_function(context: df.DurableOrchestrationContext):
# User defined configuration
instructions: str = context.get_input()
task_batch = yield context.call_activity("get_tasks", None)
# Need to pass in instructions too
parallel_tasks = [context.call_activity("perform_task", task) for task in task_batch]
results = yield context.task_all(parallel_tasks)
return results
Run Code Online (Sandbox Code Playgroud)
该perform_task活动需要来自task_batch和用户输入的项目instructions
我在我的里面做些什么function.json吗?
解决方法 不理想,但我可以将多个参数作为单个元组传递
something = yield context.call_activity("activity", ("param_1", "param_2"))
Run Code Online (Sandbox Code Playgroud)
然后我只需要引用活动中参数的正确索引。
我正在尝试在我创建的云运行模块上设置多个环境变量。我从 Terraform 中遵循的示例是静态的。是否可以动态创建这些?
\ntemplate {\n spec {\n containers {\n image = "us-docker.pkg.dev/cloudrun/container/hello"\n env {\n name = "SOURCE"\n value = "remote"\n }\n env {\n name = "TARGET"\n value = "home"\n }\n }\n }\n }\nRun Code Online (Sandbox Code Playgroud)\n\n我试过了:
\ndynamic "env" {\n for_each = var.envs\n content {\n name = each.key\n value = each.value\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n但我收到以下错误:
\n\n\n对“each.value”的引用已在其不可用的上下文中使用,例如当配置不再包含其“for_each”表达式中\n\xe2\x94\x82 中的值时。在配置中删除对 every.value 的引用以解决此错误。
\n
编辑:完整代码示例
\nresource "google_cloud_run_service" "default" {\n name = "cloudrun-srv"\n location = "us-central1"\n\n template {\n spec {\n …Run Code Online (Sandbox Code Playgroud) 我有一个列表Main(),我正尝试从一个变量中向该列表添加一个项目。但这会引发错误“当前上下文中不存在名称'dogList'”
在我的addDog()方法内部,dogList.Add()由于上述原因无法正常工作。
namespace DoggyDatabase
{
public class Program
{
public static void Main(string[] args)
{
// create the list using the Dog class
List<Dog> dogList = new List<Dog>();
// Get user input
Console.WriteLine("Dogs Name:");
string inputName = Console.ReadLine();
Console.WriteLine("Dogs Age:");
int inputAge = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Dogs Sex:");
string inputSex = Console.ReadLine();
Console.WriteLine("Dogs Breed:");
string inputBreed = Console.ReadLine();
Console.WriteLine("Dogs Colour:");
string inputColour = Console.ReadLine();
Console.WriteLine("Dogs Weight:");
int inputWeight = Convert.ToInt32(Console.ReadLine());
// add input …Run Code Online (Sandbox Code Playgroud) 我正在使用 UIKit 框架,它们的模式如下所示:
<div id="modal-id" uk-modal>
<div class="uk-modal-dialog">
<button class="uk-modal-close-default" type="button" uk-close></button>
<div class="uk-modal-header">
<h2 class="uk-modal-title">Modal Title</h2>
</div>
<div class="uk-modal-body">
<p>Lorem ipsum dolor sit amet</p>
</div>
<div class="uk-modal-footer uk-text-right">
<button class="uk-button uk-button-primary" type="button">Ok</button>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
它通过一个按钮正常打开:
<a id='open-modal' uk-toggle="target: #modal-id" href="#">Open</a>
Run Code Online (Sandbox Code Playgroud)
我想将其链接到按键,因此当按下 H 时,它会切换模态:
document.body.onkeyup = function(e){
if(e.keyCode === 72){
console.log('H key pressed');
// Toggle Modal
}
}
Run Code Online (Sandbox Code Playgroud)
我在模态按钮 id 上使用 .trigger('click') 与 Bootstrap 一起工作,但它不适用于 UIKIT
我目前将所有 html 文件都放在一个平面目录中templates/,并使用以下命令加载所有内容
tmpl := template.Must(template.ParseGlob("templates/*.html"))
Run Code Online (Sandbox Code Playgroud)
但我现在想引入一些结构并将模板放入文件夹、、components等中base。但是当我这样做时,我的网站停止工作。我想可能是上面的情况,或者也可能是我需要引用模板中的路径?
例子
{{ template "navbar" }}
Run Code Online (Sandbox Code Playgroud)
会成为
{{ template "components/navbar" }}
Run Code Online (Sandbox Code Playgroud)
有点迷茫...
目前我还使用原生 go 库而不是框架。
我正在使用云构建来克隆存储库。我可以确认存储库已成功克隆到云构建/workspace卷。
steps:
- id: 'Clone repository'
name: 'gcr.io/cloud-builders/git'
args: ['clone', $_REPO_URL]
volumes:
- name: 'ssh'
path: /root/.ssh
Run Code Online (Sandbox Code Playgroud)
然后我运行下一步来确认
- id: 'List'
name: 'alpine'
args: ['ls']
Run Code Online (Sandbox Code Playgroud)
它显示存储库位于当前目录中。但是当我尝试cd进入该目录时,该cd命令不起作用并引发错误:
ERROR: build step 3 "alpine" failed: starting step container failed: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "cd <repo-name>": executable file not found in $PATH: unknown
Run Code Online (Sandbox Code Playgroud)
我的最终目标是cd进入存储库并运行一些 git 命令。我稍后使用 alpine,因为git构建器映像不允许我使用cd其中任何一个。
ERROR: build step 3 "alpine" …Run Code Online (Sandbox Code Playgroud)