Magic Column Names(自动的列名)

本文列举了Rails框架中活动记录(Active Record)所使用的常见字段名称及其用途,包括时间戳字段、锁定版本、继承类型追踪等,并解释了这些字段如何帮助开发者更高效地进行数据库操作。
在课程的最后两章我们会提到很多列名字,它们对“活动记录”有重大意义。这儿是总
结。
1、created_at, created_on, updated_at, updated_on 用创建行的或最后更新行(_at
形式)或(_on 形式)的时间戳来自动更新。
2、lock_version Rails 将跟踪行版本号并完成乐观锁。如果表包含lock_version 的话。
3、type 由“单个表继承”使用来跟踪一个行的类型。
4、id 表主键列的缺省名字。
5、xxx_id 用xxx 的复数形式来引用表名字的外键的缺省名字。
6、xxx_count 为子表xxx 维护一个counter 缓存。
7、position 如果acts_as_list 被使用的话,它这个list 中行的位置。
8、parent_id 如果使用acts_as_tree 的话,它是对这个行的父项的引用。
function [b,varargout] = braceReference(t,idxOp) % BRACEREFERENCE Subscripted reference into a table using braces. % B = T{I,J} returns an array B created as the horizontal concatenation % of the table variables specified by J, containing only those rows % specified by I. BRACEREFERENCE throws an error if the types of the variables % are not compatible for concatenation. I and J are positive integers, % vectors of positive integers, row/variable names, cell arrays % containing one or more row/variable names, or logical vectors. T{I,J} % may also be followed by further subscripting as supported by the % variable. % Copyright 2021-2022 The MathWorks, Inc. import matlab.internal.datatypes.isColon subsType = matlab.internal.tabular.private.tabularDimension.subsType; % "import" for calls to subs2inds % '{}' is a reference to the contents of a subset of a table. If no % subscripting follows, return those contents as a single array of whatever % type they are. Any sort of subscripting may follow. try if numel(idxOp(1).Indices) ~= t.metaDim.length tabular.throwNDSubscriptError(numel(idxOp(1).Indices)) end % Translate row labels into indices (leaves logical and ':' alone) [rowIndices,numRowIndices] = t.subs2inds(idxOp(1).Indices{1},'rowDim'); % Translate variable (column) names into indices (translates logical and ':') varIndices = t.subs2inds(idxOp(1).Indices{2},'varDim',subsType.reference); % Extract the specified variables as a single array. if isscalar(varIndices) b = t.data{varIndices}; else b = t.extractData(varIndices); end % Retain only the specified rows. if isa(b,'tabular') || ismatrix(b) b = b(rowIndices,:); % without using reshape, may not have one else % The contents could have any number of dims. Treat it as 2D to get % the necessary row, and then reshape to its original dims. outSz = size(b); outSz(1) = numRowIndices; b = reshape(b(rowIndices,:), outSz); end if isscalar(idxOp) % If there's no additional subscripting, return the table contents. if nargout > 1 % Output of table brace subscripting will always be scalar error(message('MATLAB:table:TooManyOutputsBracesIndexing')); end else idxOp = idxOp(2:end); % Let b's subsref handle any remaining additional subscripting. This may % return a comma-separated list when the cascaded subscripts resolve to % multiple things, so ask for and assign to as many outputs as we're % given. That is the number of outputs on the LHS of the original expression, % or if there was no LHS, it comes from numArgumentsFromSubscript. % braceReference's output args are defined as [b,varargout] so the nargout==1 % case can avoid varargout, although that adds complexity to the nargout==0 % case. See detailed comments in parenReference. % % Also the first brace could be followed by parens or another brace that % might be using row labels inherited from t. Since b would not know % anything about the row labels, call translateAndForwardReference to % translate these row labels to numeric indices before forwarding the % subscripting expression. if nargout == 1 b = t.translateAndForwardReference(b, idxOp); elseif nargout > 1 [b,varargout{1:nargout-1}] = t.translateAndForwardReference(b, idxOp); else % nargout == 0 % Let varargout bump magic capture either one output or zero % outputs. See detailed comments in parenReference. [varargout{1:nargout}] = t.translateAndForwardReference(b, idxOp); if isempty(varargout) % There is nothing to return, remove the first output arg. clear b else % Shift the return value into the first output arg. b = varargout{1}; varargout = {}; % never any additional values end end end catch ME throw(ME); end错误使用 {} (第 89 行) 无法识别表变量名称 '孕妇身高'。 根据提示修缮代码
09-07
存在3个格式相同的dataframe变量,其变量名分别为test_df.magic_df,vivo_df,已知其内部存在时间、制式(只有NRLTE两种)、版本(test_df版本列的值为“测试版本”;magic_df版本列的值为“magic”;vivo_df版本列的值为“vivo”)、频点、小区、卡顿情况(只有卡顿不卡顿两种)等列,dataframe内所有的值均为字符串类型,且三个dataframe公用一个时间序列,也即是3个dataframe的时间列完全一致,且已按时间顺序排列好。我的目的是想比较版本测试版本magic以及测试版本vivo改变制式的差异,主要是两者制式选用不一致时,比较两者哪个决策更好。 请使用python类实现以下功能: 1.将名为test_df分别于其他两个dataframe进行对比,筛选出制式变化有差异的时刻,例如test_df在某时刻制式切换(由NR切换到LTE或者由LTE切换到NR)而对比的magic_fd在该时刻制式未发生变化,或者对比的magic_fd在某时刻制式发生切换而test_df在该时刻制式未发生变化,或者两者都发生切换,但是切换不一致,同理也需要对比test_dfvivo_df。并且统计切换制式前后的小区ID,并统计小区的持续时间,以及在小区持续期间发生的卡顿次数,计算卡顿率:小区持续期间发生卡顿的次数除以小区持续时间 .如果切换后卡顿率降低,则认为切换是有效的,否则认为无效,请利用上述统计结果分析:将上述统计出来的信息进行对比,test_df分别与magic_df、vivo_df进行对比,看对比双方切换策略不一致的时刻,卡顿率是否降低,如果降低则为有效切换,并将对比结果输出到同一个xlsx文件中的不同sheet页。
最新发布
11-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值