In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to effectively improve the efficiency of data analysis in Python. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Pandas Profiling
The effect of the tool is obvious. The following figure shows the result of a simple method called df.profile_report ():
You only need to install and import the Pandas Profiling package to use this tool.
two。 Drawing Pandas data using Cufflinks and Plotly
Most experienced data scientists or data analysts are familiar with matplotlib and pandas. In other words, you can quickly draw a simple pd.DataFrame or pd.Series by calling the .plot () method.
This is fine, but is it possible to draw an interactive, scalable, scalable panorama? It's time for Cufflinks* * to do it! (Cufflinks makes further packaging based on Plotly. ) install Cufflinks in the environment, just run it in the terminal! Pip install cufflinks-- upgrade is fine. Other methods such as .exploter _ matrix () can also provide great visualization results.
3. IPython Magic Command
IPython's "magic" is a series of enhancements to IPython based on the Python standard syntax. Magic commands include two methods: magic command (line magics): run on a single input line with the% prefix, and cell magic command (cell magics): run on multiple input lines with the% prefix. Here are some useful features provided by the IPython magic command:
% lsmagic: find all commands
If you only remember one magic order, it has to be this one. Executing the% lsmagic command will provide a list of all available magic commands. % debug: interactive debug is the most commonly used magic command. Most data scientists have encountered this situation: the block of code executed is break all the time, and you write 20 print () statements in despair, trying to output the contents of each variable. Then, when you finally fix the problem, you have to go back and delete all the print () statements again. But you don't have to do that anymore. When you encounter a problem, simply execute the% debug command to execute any part of the code you want to run.
% store: passing variables between notebook
That's a cool order, too. Suppose you spend some time cleaning the data in notebook, and now you want to test some functionality in another notebook, do you implement this function in the same notebook, or do you save the data and load it in another notebook? None of these operations are required after using the% store command! This command will store the variable, which you can retrieve in any other notebook:% store [variable] stored variable;% store-r [variable] read / retrieve stored variable.
% who: lists all global variables.
Have you ever forgotten a variable name after assigning a value to it? Or accidentally delete the cell responsible for assigning values to variables? Using the% who command, you can get a list of all global variables.
%% time: timing magic command
Use this command to get all timing information. Simply apply the%% time command to any executable code.
%% writefile: write cell contents to the file
This magic command is useful when you write a complex function or class in notebook and want to save it to an exclusive file. Simply add the%% writefile prefix to the cell of the function or class and the file name you want to save to. We can save the created function to a utils.py file, and then we can import it at will. You can do the same in other notebook, as long as you belong to the same directory as the utils.py file.
4. Formatting in Jupyter
This tool is cool! Jupyter takes into account the existence of the HTML/ CSS format in markdown.
Blue, fashionable: This is fancy!
Red, slightly flustered:
This is baaaaad!
Green, calm:
This is gooood!
5. Jupyter shortcut key
To learn and learn keyboard shortcuts, you can use the command panel: Ctrl + Shift + P to get a list of all the features of notebook. Here are some of the most basic commands:
Esc: enter command mode. In command mode, you can use the arrow keys to navigate within notebook.
In command mode:
An and B: insert a new cell above or below the current cell (Above) or below (Below).
M: the current cell is transferred to Markdown state.
Y: the current cell is transferred to the code state.
Dminute D: deletes the current cell.
Enter: the current cell returns to edit mode.
In edit mode:
Shift + Tab: provides a document string (document) for the objects you type in the current cell. Continue to use this shortcut key to recycle the document mode.
Ctrl + Shift + -: splits the current cell at the cursor.
Esc + F: find and replace the code (excluding output).
Esc + O: toggles cell output.
Select multiple cells:
Shift + Down and Shift + Up: check the cells below or above.
Shift + M: merge selected cells.
Note that when multiple cells are selected, you can batch delete / copy / cut / paste / run.
Thank you for reading! This is the end of the article on "how to effectively improve the efficiency of data analysis in Python". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.