
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 10476 Articles for Python

839 Views
To return the base 2 logarithm of the input array, use the numpy.log2() method in Python Numpy The method returns Base-2 logarithm of x. This is a scalar if x is a scalar. The 1st parameter, x is the input value, array-like. The 2nd parameter is out, a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple must have length equal to the number of outputs.The 3rd parameter is where, the condition is broadcast over the input. At ... Read More

559 Views
The natural logarithm log is the inverse of the exponential function, so that log(exp(x)) = x. The natural logarithm is logarithm in base e. The method returns the natural logarithm of x, element-wise. This is a scalar if x is a scalar. The 1st parameter is the input value, array-like. The 2nd parameter is out, a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number ... Read More

535 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 format. The second parameter is the "timezone", the Timezone information to use when displaying the datetime. If ‘UTC’, end with a Z to indicate UTC time.StepsAt first, import the required library −import numpy as npCreate an array of datetime. The 'M' type specifies datetime −arr = np.arange('2022-02-20T03:25', 6*60, 60, dtype='M8[m]')Displaying our array −print("Array...", arr)Get the datatype −print("Array datatype...", ... Read More

191 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

138 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

236 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

432 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

136 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