"NumPy diff()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-<source +<syntaxhighlight , -</source> +</syntaxhighlight>))
2번째 줄: 2번째 줄:
;NumPy.diff()
;NumPy.diff()


<source lang='python' run>
<syntaxhighlight lang='python' run>
import numpy as np
import numpy as np
x = np.array([1, 2, 4, 7, 0])
x = np.array([1, 2, 4, 7, 0])
print( np.diff(x) )      # [ 1  2  3 -7]
print( np.diff(x) )      # [ 1  2  3 -7]
print( np.diff(x, n=2) ) # [  1  1 -10]
print( np.diff(x, n=2) ) # [  1  1 -10]
</source>
</syntaxhighlight>
<source lang='python' run>
<syntaxhighlight lang='python' run>
import numpy as np
import numpy as np
x = np.array([[1, 3, 6, 10], [0, 5, 6, 8]])
x = np.array([[1, 3, 6, 10], [0, 5, 6, 8]])
14번째 줄: 14번째 줄:
                     #  [5 1 2]]
                     #  [5 1 2]]
print( np.diff(x, axis=0) ) # [[-1  2  0 -2]]
print( np.diff(x, axis=0) ) # [[-1  2  0 -2]]
</source>
</syntaxhighlight>
<source lang='python' run>
<syntaxhighlight lang='python' run>
import numpy as np
import numpy as np
x = np.arange('1066-10-13', '1066-10-16', dtype=np.datetime64)
x = np.arange('1066-10-13', '1066-10-16', dtype=np.datetime64)
print( np.diff(x) )  
print( np.diff(x) )  
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2021년 5월 13일 (목) 21:45 판

1 개요

NumPy.diff()
import numpy as np
x = np.array([1, 2, 4, 7, 0])
print( np.diff(x) )      # [ 1  2  3 -7]
print( np.diff(x, n=2) ) # [  1   1 -10]
import numpy as np
x = np.array([[1, 3, 6, 10], [0, 5, 6, 8]])
print( np.diff(x) ) # [[2 3 4]
                    #  [5 1 2]]
print( np.diff(x, axis=0) ) # [[-1  2  0 -2]]
import numpy as np
x = np.arange('1066-10-13', '1066-10-16', dtype=np.datetime64)
print( np.diff(x) )

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}