为什么Laravel 4 gitignore composer.lock(why does Laravel 4 gitignore composer.lock)
为什么默认的laravel4有.gitignore repo中包含的composer.lock文件?
Why does the default laravel4 have the composer.lock file included in the .gitignore repo?
It seems to contradict composers recommendations to commit this file into VCS. I was wondering if there was something I didn't know that justified this?
原文:https://stackoverflow.com/questions/21505020
最满意答案
SFrame是不可变的,因此它们实际上不支持项目分配。 你在这里看到差异的原因是因为
sf[1]['test']
实际上并不是指SFrame。 “sf [1]”返回一个字典,其中包含与SFrame列名匹配的键,以及与SFrame第二行匹配的值。 当您为“sf [1] ['test']”分配一个数字时,您正在更改返回的字典中的“test”键的值,因此SFrame“sf”不参与分配。 仅引用“test”列的第二个值并赋值“3”的正确方法是:
sf['test'][1] = 3
哪会返回此错误:
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-5-c52dab41d5dd> in <module>() ----> 1 sf['test'][1] = 3 TypeError: 'SArray' object does not support item assignment
SFrames are immutable, so they don't actually support item assignment. The reason for the difference you see here is because
sf[1]['test']
isn't actually referring to the SFrame at all. "sf[1]" returns a dictionary with keys that match to the SFrame's column names, and values that match the second row of the SFrame. When you assign a number to "sf[1]['test']", you are changing the value of the "test" key in the dictionary that was returned, so the SFrame "sf" is not involved in the assignment. The correct way to reference only the second value of the column "test" and assign the value "3" is this:
sf['test'][1] = 3
which would return this error:
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-5-c52dab41d5dd> in <module>() ----> 1 sf['test'][1] = 3 TypeError: 'SArray' object does not support item assignment
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
SFrame是不可变的,因此它们实际上不支持项目分配。 你在这里看到差异的原因是因为 sf[1]['test'] 实际上并不是指SFrame。 “sf [1]”返回一个字典,其中包含与SFrame列名匹配的键,以及与SFrame第二行匹配的值。 当您为“sf [1] ['test']”分配一个数字时,您正在更改返回的字典中的“test”键的值,因此SFrame“sf”不参与分配。 仅引用“test”列的第二个值并赋值“3”的正确方法是: sf['test'][1] = 3 哪会返回此错误: ------ ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
这是一个内置的命令: graphlab.SFrame.add_row_number(column_name, start) 您可以在此处的文档中找到有关它的更多信息 There's an inbuilt command for just that: graphlab.SFrame.add_row_number(column_name, start) You can find out more about it in the documentation here
-
我认为您可以使用布尔数组来标识给定列的缺失值的行。 >>> import graphlab >>> sf = graphlab.SFrame({'a': [1, 2, None, 4], ... 'b': [None, 3, 1, None]}) >>> mask = sf['a'] == None >>> mask dtype: int Rows: 4 [0, 0, 1, 0] I think you can use a boolean array to id ...
-
SFrame中的每一行都是一个python字典,其中键是列名,值是此列下的值。 所以我认为你应该先获得最低值的密钥,然后将其作为字符串进行比较。 如果是狗返回1否则返回0 。 喜欢: if min(dog_distances[#row], key=dog_distances.get) == "dog-dog": ## the first part of the line will return the column name return 1 else: return 0 并使用apply ...
-
我认为你最好的选择是将SFrame和SArray转换为numpy数组并使用numpy dot方法。 import graphlab sf = graphlab.SFrame({'a': [1., 2.], 'b': [3., 5.], 'c': [7., 11]}) sa = graphlab.SArray([1., 2., 3.]) X = sf.to_dataframe().values y = sa.to_numpy() ans = X.dot(y) 我在这里使用的数据比您所使用的数据简单,但 ...
-
根据文档,您可以使用list(sarray)转换回标准列表。 然后可以使用pd.Series(new_list)将其转换为pandas系列。 According to the docs you can use list(sarray) to convert back to a standard list. This can then be converted to a pandas series with pd.Series(new_list).
-
>>> import graphlab as gl >>> sf = gl.SFrame({'foo':[1,2,3], 'bar':[4,5,6]}) >>> sf Columns: bar int foo int Rows: 3 Data: +-----+-----+ | bar | foo | +-----+-----+ | 4 | 1 | | 5 | 2 | | 6 | 3 | +-----+-----+ [3 rows x ...
-
您可以使用以下替代代码: 只需在原始Sframe中创建一个新列'Pclass_',然后您就可以: df['Pclass_'] = [1 if item == 38 else 2 if item == 30 else 3 if item == 26 else 4 for item in df['Age']] 您可以在列表中使用任何类型的(if-else-if)条件。 You can use alternative code as below: Just create a new column 'Pclass ...