How to use NumPy to find the maximum and minimum values in an array

Source: Internet
Author: User
This time to bring you how to use NumPy to find the maximum and minimum values in the array, with NumPy to find out the maximum and minimum values in the array of considerations, the following is the actual case, together to see.

Create an array using NumPy in Python, and then we want to get the maximum value of the array, the minimum value. You can use this method:

First, create an array

This allows you to get the maximum and minimum values for an array.

And you can use Np.where (Np.max (a)) to get the maximum, minimum number of rows and columns.

Second, the operation of the file under Python

1. Move a folder to another folder

First of all

Import OS, Skutil

To copy a file:

Shutil.copyfile (' Oldfile ', ' newfile ')

Oldfile and NewFile can only be files.

Shutil.copy (' Oldfile ', ' newfile ')

Oldfile can only be a folder, NewFile may be a file, or it can be a destination directory

To copy a folder:

Shutil.copytree (' Olddir ', ' newdir ')

Olddir and Newdir can only be directories, and newdir must not exist

To move a file:

Shutil.move (' Oldpos ', ' Newpos ')

To rename a file:

Os.rename (' oldname ', ' newname ') files and directories use this command

To delete a file:

Os.remove (' file ') os.rmdir (' dir ')

Only empty directories can be deleted

Judgment target:

Os.path.exists (' goal ')

Determine if the target exists

Os.path.isdir (' goal ')

Determine if the target is a directory

Os.path.isfile (' goal ')

Determine if the target is a file

To convert a directory:

Os.chdir (' path ')

Determine if the path exists:

isexists = os.path.exists (path)

Exists True

does not exist False

To create a directory:

Os.mkdir (' file ')

To create a multi-level catalog:

def mkdirs (path): # Remove First space path = Path.strip () # remove tail \ Symbol Path = Path.rstrip (' \ \ ')

Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!

Recommended reading:

How Python strings are converted to two-dimensional arrays

The object of diff is the virtual Dom

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.