
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

194 Views
To convert an array of datetimes into an array of strings, use the numpy.datetime_as_string() method in Python Numpy. The method returns an array of strings the same shape as the input array. The first parameter is the array of UTC timestamps to formatStepsAt first, import the required library −import numpy as npCreate an array of datetime. The 'M' type specifies datetime −arr = np.arange('2022-02-20T02:10', 6*60, 60, dtype='M8[m]')Displaying our array −print("Array...", arr)Get the datatype −print("Array datatype...", arr.dtype) Get the dimensions of the Array −print("Array Dimensions...", arr.ndim)Get the shape of the Array −print("Our Array Shape...", arr.shape)Get the number of elements of the ... Read More

2K+ Views
To return the length of a string array element-wise, use the numpy.char.str_len() method in Python Numpy. The method returns an output array of integers.StepsAt first, import the required library −import numpy as npCreate a One-Dimensional array of strings −arr = np.array(['Amy', 'Scarlett', 'Katie', 'Brad', 'Tom'])Displaying our array −print("Array...", arr)Get the datatype −print("Array datatype...", arr.dtype) Get the dimensions of the Array −print("Array Dimensions...", arr.ndim)Get the shape of the Array −print("Our Array Shape...", arr.shape)Get the number of elements of the Array −print("Number of elements in the Array...", arr.size)To return the length of a string array element-wise, use the numpy.char.str_len() method −print("Result (length ... Read More

140 Views
Return the highest index in the string where substring sub is found using the numpy.char.rindex() method in Python Numpy. The method returns the output array of ints. Raises ValueError if sub is not found. The first parameter is the input array. The second parameter is the substring to be searched. The third and fourth parameter are optional arguments, wherein start and end are interpreted as in slice notation.StepsAt first, import the required library −import numpy as npCreate a One-Dimensional array of strings −arr = np.array(['KATIE', 'KATE', 'BRATleukATp'])Displaying our array −print("Array...", arr)Get the datatype −print("Array datatype...", arr.dtype) Get the dimensions of ... Read More

237 Views
To return the highest index in the string where substring sub is found, use the numpy.char.rfind() method in Python Numpy. The method returns the output array of ints. Returns -1 if sub is not found.The first parameter is the input array. The second parameter is the substring to be searched. The third and fourth parameter are optional arguments, wherein start and end are interpreted as in slice notation.StepsAt first, import the required library −import numpy as npCreate a One-Dimensional array of strings −arr = np.array(['KATIE', 'JOHN', 'AmY', 'BRATleuATp'])Displaying our array −print("Array...", arr)Get the datatype −print("Array datatype...", arr.dtype) Get the dimensions ... Read More

112 Views
To return the highest index in the string where substring sub is found, use the numpy.char.rfind() method in Python Numpy. The method returns the output array of ints. Returns -1 if sub is not found. The first parameter is the input array. The second parameter is the substring to be searchedStepsAt first, import the required library −import numpy as npCreate a One-Dimensional array of strings −arr = np.array(['KATIE', 'JOHN', 'AmY', 'BRATleuATp'])Displaying our array −print("Array...", arr)Get the datatype −print("Array datatype...", arr.dtype) Get the dimensions of the Array −print("Array Dimensions...", arr.ndim)Get the shape of the Array −print("Our Array Shape...", arr.shape)Get the number ... Read More

436 Views
To return a boolean array which is True where the string element in array begins with prefix, use the numpy.char.startswith() method in Python Numpy. The method outputs an array of bools. The first parameter is the input array. The second parameter is the prefix. With optional start parameter, test beginning at that position. With optional end parameter, stop comparing at that position.StepsAt first, import the required library −import numpy as npCreate a One-Dimensional array of strings −arr = np.array(['KATIE', 'JOHN', 'KATE', 'KmY', 'BRAD'])Displaying our array −print("Array...", arr)Get the datatype −print("Array datatype...", arr.dtype) Get the dimensions of the Array −print("Array Dimensions...", ... Read More

138 Views
To return the lowest index in the string where substring sub is found, use the numpy.char.find() method in Python Numpy. The method returns the output array of ints. Returns -1 if sub is not found. The first parameter is the input array. The second parameter is the substring to be searchedStepsAt first, import the required library −import numpy as npCreate a One-Dimensional array of strings −arr = np.array(['KATIE', 'JOHN', 'KATE', 'AmY', 'BRADley'])Displaying our array −print("Array...", arr)Get the datatype −print("Array datatype...", arr.dtype) Get the dimensions of the Array −print("Array Dimensions...", arr.ndim)Get the shape of the Array −print("Our Array Shape...", arr.shape)Get the ... Read More

179 Views
To return a boolean array which is True where the string element in array ends with suffix, use the numpy.char.endswith() method in Python Numpy. The method outputs an array of bools. The first parameter is the input array. The second parameter is the suffix. With optional start parameter, test beginning at that position. With optional end parameter, stop comparing at that position.StepsAt first, import the required library −import numpy as npCreate a One-Dimensional array of strings −arr = np.array(['KATIE', 'JOHN', 'KATE', 'AmY', 'CRADlE'])Displaying our array −print("Array...", arr)Get the datatype −print("Array datatype...", arr.dtype) Get the dimensions of the Array −print("Array Dimensions...", ... Read More

92 Views
To test whether similar int type of different sizes are subdtypes of integer class, use the numpy.issubdtype() method in Python Numpy. The parameters are the dtype or object coercible to one.StepsAt first, import the required library −import numpy as npUsing the issubdtype() method in Numpy. Checking for integer datatype with different sizes −print("Result...", np.issubdtype(np.int16, np.signedinteger)) print("Result...", np.issubdtype(np.int32, np.signedinteger)) print("Result...", np.issubdtype(np.int64, np.signedinteger)) print("Result...", np.issubdtype(np.int16, np.integer)) print("Result...", np.issubdtype(np.int32, np.integer)) print("Result...", np.issubdtype(np.int64, np.integer))Exampleimport numpy as np # To test whether similar int type of different sizes are subdtypes of integer class, use the numpy.issubdtype() method in Python Numpy. # The parameters are ... Read More

310 Views
The gradient is computed using second order accurate central differences in the interior points and either first or second order accurate one-sides (forward or backwards) differences at the boundaries. The returned gradient hence has the same shape as the input array. The 1st parameter, f is an Ndimensional array containing samples of a scalar function. The 2nd parameter is the varargs i.e. the spacing between f values. Default unitary spacing for all dimensions.The 3rd parameter is the edge_order{1, 2} i.e. the Gradient is calculated using N-th order accurate differences at the boundaries. Default: 1. The 4th parameter is the Gradient, ... Read More