我正在阅读Practical Common Lisp.在第11章中,它说明了有关排序:
通常,在对序列进行排序后,您不会关心序列的未排序版本,因此在排序过程中允许
SORT和STABLE-SORT销毁序列是有意义的.但它确实意味着你需要记住写下面的内容:Run Code Online (Sandbox Code Playgroud)(setf my-sequence (sort my-sequence #'string<))
我尝试了以下代码:
CL-USER> (defparameter *a* #( 8 4 3 9 5 9 2 3 9 2 9 4 3))
*A*
CL-USER> *a*
#(8 4 3 9 5 9 2 3 9 2 9 4 3)
CL-USER> (sort *a* #'<)
#(2 2 3 3 3 4 4 5 8 9 9 9 9)
CL-USER> *a*
#(2 2 3 3 3 4 4 5 8 9 …Run Code Online (Sandbox Code Playgroud) 我必须删除不向数据集添加信息的列,即所有条目中具有相同值的列。
我设计了两种方法来做到这一点
for col in df.columns:
if df.agg(F.min(col)).collect()[0][0] == df.agg(F.max(col)).collect()[0][0]:
df = df.drop(col)
Run Code Online (Sandbox Code Playgroud)
for col in df.columns:
if df.select(col).distinct().count() == 1:
df = df.drop(col)
Run Code Online (Sandbox Code Playgroud)
有没有更好、更快或更直接的方法来做到这一点?