小编lui*_*aco的帖子

Angular ui-选择多个清理ng模型值

我正在尝试使用ui-select,组件正在清理我的数组.

例:

{{ vm.staff_hotels }}
<ui-select multiple ng-model="x" theme="bootstrap">
    <ui-select-match placeholder="Not selected">{{$item.name}}</ui-select-match>
    <ui-select-choices repeat="hotel.id as hotel in vm.hotels | filter: {active: true} | filter: $select.search">
        <div ng-bind-html="hotel.name | highlight: $select.search"></div>
    </ui-select-choices>
</ui-select>
Run Code Online (Sandbox Code Playgroud)

屏幕上的变量"vm.staff_hotels"值为[1,2].

{{ vm.staff_hotels }}
<ui-select multiple ng-model="vm.staff_hotels" theme="bootstrap">
    <ui-select-match placeholder="Not selected">{{$item.name}}</ui-select-match>
    <ui-select-choices repeat="hotel.id as hotel in vm.hotels | filter: {active: true} | filter: $select.search">
        <div ng-bind-html="hotel.name | highlight: $select.search"></div>
    </ui-select-choices>
</ui-select>
Run Code Online (Sandbox Code Playgroud)

但是,如果我在ng-model中使用变量,我的值会更改为[null,null].

html javascript frontend angularjs ui-select

19
推荐指数
1
解决办法
1345
查看次数

将Pandas的pivot_table函数转换为Polars的pivot函数

我正在尝试将一些蟒蛇熊猫转换为极地。我一直试图将 pandas hub_table 函数转换为极坐标。以下是工作的 pandas 代码。我似乎无法通过 Polars 枢轴函数获得相同的行为。Polars 枢轴函数强制列参数并使用列值作为标题而不是列标签作为标题。我将使用下面相同的输出,但使用 Polars 而不是 Pandas。

df = pd.DataFrame({"obj" : ["ring", "shoe", "ring"], "price":["65", "42", "65"], "value":["53", "55", "54"], "date":["2022-02-07", "2022-01-07", "2022-03-07"]})

table = pd.pivot_table(df, values=['price','value','date'],index=['obj'], aggfunc={'price': pd.Series.nunique,'value':pd.Series.nunique,'date':pd.Series.nunique})

print(table)
Run Code Online (Sandbox Code Playgroud)

输出以下内容:

        date    price     value  
obj  
ring    2       1         2  
shoe    1       1         1
Run Code Online (Sandbox Code Playgroud)

python pandas python-polars

3
推荐指数
1
解决办法
3764
查看次数