• 09 August

    Python | cv2 imwrite() Method

    In this tutorial, we will see how to save an image in your own system using python by using open-cv which exists as cv2 (computer vision) library. You can use imwrite() method of cv2 library to save an image on your system. To use cv2 library, you need to import cv2 library using import statement. […]

  • 27 December

    Create Array of All NaN Values in Python

    Using numpy.empty() Function To create an array of all NaN values in Python: Use numpy.empty() to get an array of the given shape. Assign numpy.nan to every array element using the assignment operator (=). [crayon-63da53c2bf3e6901562645/] [crayon-63da53c2bf3ef267524294/] We used numpy.empty() to get an array of the given shape and dtype. Here, shape means the number of […]

  • 27 December

    Call Function from Another Function in Python

    Call a Function in Python To call a function in Python: Write a test() function, which prints a message. Call the function defined in the previous step. [crayon-63da53c2bf5d8817799760/] [crayon-63da53c2bf5dd232826244/] To call a function, we have to define that function using the def keyword, so we used that to define the test() function. Then, inside the […]

  • 27 December

    [Fixed] NameError Name ‘unicode’ is Not Defined in Python

    Use str() Method To resolve the NameError: name 'unicode' is not defined, replace the occurrence of unicode() with str(). This issue occurs because unicode() was renamed to str() in Python 3. [crayon-63da53c2bf708235376274/] [crayon-63da53c2bf70b088151755/] Unicode is a computing industry standard that ensures that text from most of the world’s writing systems is consistently encoded, rendered, and […]

  • 26 December

    Repeat List N Times in Python

    This tutorial will demonstrate how to repeat list n times in Python. Using the * operator To repeat list n times in Python, use the * operator. Star operator(*) is used to multiply list by number e.g. lst*3 and this will repeat list 3 times. See the code below. [crayon-63da53c2bf7e6607473695/] Output: [2, 4, 6, 11, […]

  • 26 December

    Get First Day of Next Month in Python

    Get First Day of Next Month in Python This tutorial will demonstrate how to get first day of next month in Python. Using the datetime.replace() with datetime.timedelta() function To get first day of next month in Python: Use the datetime object to store the current date and time. Use the datetime.replace() and datetime.timedelta() function to […]

  • 25 December

    Convert String Array to Int Array in Python

    This tutorial will demonstrate how to convert string array to int array in Python. Using the for loop with int() function To convert string array to int array in Python: Use the for loop to loop through the array. Use the int() function to convert each element to an integer in every iteration. See the […]

  • 25 December

    Encode String to UTF-8 in Python

    The UTF-8 encoding is used by default in Python and represents 8-bit Unicode values. The upgrade to Python 3 saw a major change in using ASCII characters to Unicode characters by default for strings. Encode String to UTF-8 in Python This tutorial will demonstrate how to encode string to UTF-8 in Python. Using the encode() […]

  • 23 December

    Remove All Non-numeric Characters in Pandas

    Using Pandas Series.str.extract() Method To remove all non-numeric characters from one column in pandas: After creating the data frame, use the Series.str.extract() method to extract numeric parts. [crayon-63da53c2bfb01996429321/] [crayon-63da53c2bfb04566966160/] In this code, we used the Series.str.extract() method to extract numeric parts from one column in pandas, which indirectly means we removed all non-numeric characters from […]

  • 23 December

    How To Do Line Continuation in Python

    Using Backslash (\) Operator We can use \ operator for line continuation in string and number expression as follows. Line Continuation in String To do line continuation in Python Strings: Use the backslash operator to do line continuation for writing strings in Python. [crayon-63da53c2c01e8692075288/] [crayon-63da53c2c01ef853585179/] A backslash (\) is an explicit line break operator in […]