Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the methods to quickly improve the ability of web data analysis?

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what are the methods to quickly improve the ability of web data analysis". In the daily operation, I believe that many people have doubts about the methods that quickly improve the ability of web data analysis. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "what are the methods to improve the ability of web data analysis quickly?" Next, please follow the editor to study!

# 1: Pandas Profiling

The advantages of this tool are obvious. The following animation is the result of the simple method of using df.profile_report (). Please watch the results show for yourself.

To use this tool, you only need to install and import the Pandas Profiling package.

# 2: use Cufflinks and Plotly to draw Panda data

Most so-called "experienced" data scientists or data analysts are familiar with the synergy of matplotlib and pandas. That is, they can quickly draw pd.DataFrame or pd.Series images by using the .plot () function.

Kind of boring, huh?

It's all right now. How to make an interactive panoramic scalable image? Cufflinks can do it! (provided by Plotly)

Just install Cufflinks in the system! Quickly install Cufflinks-just update it on your favorite terminal. You can watch the following animations:

Much better!

Note that the only thing that will change the above results is to input the Cufflinks and set the cf.go_offline () function. The rest is just changing .plot () to .iplot ().

Other functions such as .scatter _ matrix () bring good visual images:

Cool!

Hope that friends engaged in a large number of data visualization work will take a look at the relevant Cufflinks and Plotly content, from which you can find a large number of methods!

# 3: IPython Magic Commands

IPython's Magics is essentially a series of enhancements that IPython stacks on top of the Python syntax. There are two types of Magic commands: line magics, prefixed with%, running on one line of input code, and cell magics prefixed with%%, running on multiple lines of input code. Here are some practical functions of Magics:

% lsmagic: everything.

You might as well try some traditional but useful methods first. If you only remember one Magic Command, it's probably it. Executing% lsmagic will result in a list of all available Magic Commands:

% debug: interactive program debugging

This is estimated to be the most frequently used Magic Command.

Most people have tried: programmers execute a block of code that goes wrong all the time. Desperate programmers write code like 20 print () in order to output the contents of each variable. Then when the programmer finally fixes the problem, he has to go back and delete all the listed functions.

But now I don't need it! Just execute% debug when you encounter a problem, and you can execute any part of the code:

So, sum up the above:

1. There is a function that takes a list as input and squares all even numbers.

two。 Run the function and there is an error somewhere. But the error could not be found.

3. Mark the% debug command into the function when there is an error.

4. Let the debugger display the values of x and type (x).

5. As a result, an error is found: 6 is treated as a string!

As you can imagine, this command is very useful for more and more complex functions!

% store: passing variables between notebooks

That's a great order, too. First of all, let's talk about the cause. The programmer took the time to clean up some of the data in the notebook, and now he needs to test some functions in another notebook, so he needs to implement the function in the same notebook and put it in another notebook. With% store, simply store the variable and retrieve it in any notebook:

% store [variable] stores variables.

% store-r [variable] read / retrieve stored variables.

% who: lists all variables.

Have you ever assigned a value to a variable but forgot the variable name? Did you accidentally delete the cell assigned to the variable? With% who, you can get all the assigned variables:

%% time: magic timing.

With this command, you can get all the timing information you need. As long as%% time is applied to any piece of executable code, you get the following output:

24 microseconds. Just so-so.

%% writefile: edit the contents of the cell to the document.

This is the last command of this article. This command is useful when you have written some complex functions or their categories in notebook and want to separate them from notebook to a file. Simply add the leading%% writefile to the function or its category, and then add the file name storage:

As shown in the figure, you can directly save the created function to the "utils.py" folder and import the function in any form. The same is true in other notebook! (as long as they are all in the same directory in the utils.py folder)

# 4: gorgeous format in Jupyter

This is great! Basically, Jupyter allows you to set some HTML / CSS formats in markdown cells. Here are some common ones:

Melancholy and stylish:

This is fancy!

Warm-blooded and slightly painful:

This is baaaaad!

Green and calm:

This is gooood!

Here is the action animation:

These commands are very useful when it comes to presenting results in notebook form!

# 5: shortcut keys for Jupyter

After you have learned keyboard shortcuts, you can use the command panel: Ctrl + Shift + P. This operation can directly evoke the list of functions in notebook. The following are some of the basic commands:

Esc: use this shortcut to switch directly to command mode. This is also the way to navigate through notebook with arrow keys.

When in command mode:

An and B: type a new cell, move up ([A] bove) or move down ([B] elow) an existing cell.

M: markdown the existing cell ([M] arkdown).

Y: change the existing cell to code.

D efinetly D: confirm to delete ([D] efinetly [D] eletes) existing cells.

Enter: returns the edit mode to an existing cell.

When in edit mode:

Shift + Tab: display Docstring (document string) for targets that type existing cells-long press the shortcut key to switch document mode.

Ctrl + Shift + -: detaches existing cells from the cursor pause.

Esc + F: find and replace code that does not contain output.

Esc + O: toggles cell output.

Select multiple cells:

Shift + Down and Shift + Up: select the next cell down or up. Personally, I think we can use the deductive method to distinguish.

Shift + M: merge selected cells.

Note that once the cell is selected, you can delete / copy / paste / run in batches.

# 6: Jupyter (or IPython) multiple outputs per cell

This is good, too. Have you ever wanted to display the .head () and the .tail () of pandas data frames (DataFrame)? But give up halfway, because it's too troublesome to create an extra code cell to run .tail (). Don't be afraid, now use the following code to display all the desired output:

From IPython.core.interactiveshell import InteractiveShell

InteractiveShell.ast_node_interactivity = "all"

Look, the strength of multiple outputs is here:

It's a piece of cake.

# 7: constantly expand your Jupyter notebook

With RISE, you can gradually convert Jupyter Notebook into a slideshow. Best of all, notebook is still available, so you can code the presentation in real time at the same time!

Depending on your system environment, you can install RISE through conda or pip to use the tool:

Conda install-c conda-forge rise

/ OR /

Pip install RISE

You can now click the new button to create a presentation from notebook:

At this point, the study of "what are the ways to quickly improve the ability of web data analysis" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report