Python numpy Array read-in, storage operations

Source: Internet
Author: User
Tags sin

Loading a ndarray array from a file
    • Loads the Ndarray array from the text file Np.loadtxt

      >>># textfile是文本文件
    • .npyloads the Ndarray array from or to the .npz file Np.load
      Returns a single Ndarray array if it is a file that ends in. npy
      Returns a dictionary type object, {Filename:array}, if it is a file that ends in. Npz.

      >>># textfile是.npz或.npy结尾的二进制文件
Depositing a ndarray array into a file
  • Deposit a single Ndarray array into a binary file Np.save

    >>>= np.arange(10>>># outfile必须以.npy结尾
  • Depositing multiple ndarray arrays into a binary file Np.savez

    >>>= np.arange(10>>>= np.sin(x)>>># outfile必须以.npz结尾
  • Save the Ndarray array in a text file Np.savetxt

    >>>= np.arange(10>>>= np.sin(x)>>> np.savetext(outfile, x, delimiter=‘,‘# outfile为文本文件>>> np.savetext(outfile, (x,y))>>> np.savetext(outfile, x, fmt=‘%1.4e‘)

Python numpy Array read-in, storage operations

Related Article

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.