Using Python for data analysis (3) using IPython to improve development efficiency, pythonipython

Source: Internet
Author: User

Using Python for data analysis (3) using IPython to improve development efficiency, pythonipython
I. Introduction to IPython
IPython is an interactive Python interpreter and is more efficient. Unlike most traditional working modes (edit-> compile-> RUN), it adopts the following working modes: Execution-> exploration, most data analysis-related code contains exploratory operations (such as trial and iterative methods), so IPython can greatly improve coding efficiency.
Since the development of IPython, it is not just an enhanced version of Python shell, it integrates the GUI console, which allows you to directly perform drawing operations; it also has a Web-based notebook and a lightweight fast parallel computing engine.

2. write code
Enter ipython in Terminal to start IPython. If you need to use the Matplotlib library, you need to mark the integration of the Matplotlib package at startup, then the startup command is changed to: ipython -- pylab
1. Learn to use the Tab key
When you enter the code, if this is a previously entered content (such as the variable defined earlier ), you only need to press the Tab key after entering the first few letters to automatically complete. IPython has this function as a major improvement to the standard Python shell, which is already very common in IDE in other languages.
It can not only automatically complete variables and objects, but also automatically complete the file path as if you typed the command in Terminal.
2. Press the up and down arrow keys to quickly enter History commands.
When a command or code needs to be repeatedly input, you do not have to manually repeat it each time. You only need to use the up arrow to automatically complete the previous command; then press the arrow key to run the preceding command. If you need to press the arrow key multiple times to find a command, you only need to enter the first few letters of the command and then press the arrow key to filter only the commands that match the first few letters.
3. Execute a. py file.
If you want to execute an external. py file, use the % run command, for example, Ctrl + F move the cursor forward by 1 Character

  • Ctrl + B move the cursor one character behind
  • Ctrl + A move the cursor to the beginning of the line
  • Ctrl + E move the cursor to the end of the row
  • Ctrl + U delete all content before this row cursor
  • Ctrl + K delete all content after this row cursor
  • Ctrl + L clear screen (Cmd + K under Mac)

  • Iii. Code debugging
    1. Start the debugger when an exception occurs in the code
    If an exception occurs in the code, enter the % debug command to start the debugger and automatically jump to the "event location": Enter the q command to exit the debugger.
    2. One-step execution
    You can use the % run command with the-d option to open the debugger in advance, enter the s step into the function call, enter the n command to execute the next line of code, and enter the exclamation point (!) Enter the variable name to view the value of the variable. For example, the next article is: Using Python for data analysis (4) NumPy basics-ndarray and vector computing. If you are interested, please follow this blog, you are also welcome to add comments for discussion.

    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.