Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use pandas to make score strips in Python

Shulou Source: shulou.com Published: 2022-06-02 07:57:24 09月20日 Update

It is believed that many inexperienced people don't know what to do about how to use pandas to make score strips in Python. Therefore, this paper summarizes the causes and solutions of the problems. Through this article, I hope you can solve this problem.

Excel skills

Can this work be done in batches with Excel's own features? Of course, but it takes a lot of skill. But I always say that ideas are more important than methods, because if you understand the Excel operation process, the same idea can be applied to pandas.

Take a look at how Excel accomplishes this requirement, and we demonstrate it with 10 records:

Add an auxiliary sequence with each value separated by 2 (this is because the resulting data is separated by 2 rows)

Under the secondary column, generate the sequence (the ending value is the Mantissa of the previous sequence)

You can use the build series function that comes with Excel.

Add title rows in batch

Starting at 3, set a title every three lines

Remove duplicate sequence lines

Finally, the result can be obtained by sorting according to the auxiliary column.

Pandas practice

There are many ways to implement pandas. This section first introduces the ways that are basically consistent with the solution of Excel mentioned above. As follows:

Modify the row index value, which is equivalent to the first step of Excel

Reindex can give index values to rows that do not exist, and those rows will become blank lines

Equivalent to the second and fourth steps in Excel

Finally, starting with index 3, you can assign column headings every three rows

The complete code is as follows:

After reading the above, have you mastered how to use pandas to make score strips in Python? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Sequence idea method title index assistant achievement production content function skill way more result this is problem generation important consistent helpless Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Information OPPO Reno Shulou Technology macOS