Python中的numpy.flipud()用法示例介绍

2021年4月10日12:49:22 发表评论 1,013 次浏览

numpy.flipud()函数的作用是:按上下方向翻转数组(每一列中的项),形状保持不变。

语法如下:

numpy.flipud(array)

参数:

array : [array_like]Input array, we want to flip

返回:

Flipped array in up-down direction.
# Python Program illustrating
# numpy.flipud() method
  
import numpy as geek
  
array = geek.arange( 8 ).reshape(( 2 , 2 , 2 ))
print ( "Original array : \n" , array)
  
# flipud : means flip up-down
print ( "\nFlipped array : \n" , geek.flipud(array))

输出:

Original array : 
 [[[0 1]
  [2 3]]

 [[4 5]
  [6 7]]]

Flipped array : 
 [[[4 5]
  [6 7]]

 [[0 1]
  [2 3]]]

参考文献:

https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.flipud.html#numpy.flipud

如果发现任何不正确的地方, 或者想分享有关上述主题的更多信息, 请写评论。

首先, 你的面试准备可通过以下方式增强你的数据结构概念:Python DS课程。

木子山

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: