When using Python to process and analyze data, the most used is Pandas. Since Pandas is a very powerful tool and involves a lot of functions, it is often necessary to consult the documentation when using it. Here is a record of some of the functions and knowledge points that you commonly use. Introduction to Pandas Pandas is a data analysis package for python, originally developed by AQR Capital Management
Python Exception Catching and Handling
What is an exception? An exception is an event that occurs during program execution and affects the normal execution of the program. Typically, an exception occurs when Python is unable to process a program properly. Exceptions are Python objects that represent an error. When an exception occurs in a Python script we need to catch it and handle it, otherwise the program will terminate execution. When an uncaught exception occurs,
Python String Formatting Tool
There are two string formatting schemes in Python, one is the % operator that existed before Python 2.6, and the other is a new string formatting function str.format() that has been added since Python 2.6. % Formatting Tool Students familiar with the C printf() function will easily learn the %formatting tool. print() uses conversion specifiers beginning with % to format output for various types of data. Output of integers. %o
Python built-in functions
Python’s design philosophy is “small core language” + “large standard library”, so when Python wants to add a new feature, it is more likely to think about whether to add it to the core language support or put it into the library as an extension. library is very large and contains many modules. To use a function, you must import the corresponding module in advance, otherwise the function is invalid.
If __name__ == '__main__' in Python
In the process of learning Python, or reading other code written to it, you will encounter code like this.
1 2 if __name__ == "__main__": print("Hello World!") We found that even if we remove the if __name__ == '__main__', the program still runs as usual. Many of you only know that this is how it works, and you don’t look deeper into what exactly it does.
Program entrance For many programming languages, a program must have an entry point, such as C, C++, and the fully object-oriented programming languages Java, C#, and so on.
Understand declval and decltype
std::declval and decltype About decltype decltype(expr) is a new keyword added to C++11 to type out entities or expressions.
1 2 3 4 5 6 #include <iostream> int main() { int i = 33; decltype(i) j = i * 2; std::cout << j; } It is simple and needs no additional explanation.
But how can something so simple require such a big thing as a new keyword? It’s metaprogramming! In the world of metaprogramming, a long string of template class declarations is crippling, and writing them repeatedly is even more tedious.
In-depth understanding of Python with statements
What is a with statement? The with statement is a feature related to exception handling introduced in Python 2.6. The with statement is used when accessing resources to ensure that the necessary “cleanup” operations are performed to release resources, such as automatic closure of files after use, automatic acquisition and release of locks in threads, and so on, regardless of whether an exception occurs during use. automatically after a file is used, automatic acquisition and release of locks in threads, etc.
Python error Unable to find vcvarsall.bat
Python error Unable to find vcvarsall.bat error is the most impressive problem I’ve encountered when installing Python packages on Windows platforms. This solution was compiled on September 10, 2012. Nine years have passed, and I believe there are still many of you who encountered similar problems. I took the time to recreate the previous solution and sort it out. The main change is to add the solution under Python2.
Problem Cause If the package/module you installed has contents written in cpython, you need to compile the middle C code into a binary file before the installation can be completed successfully.
In-depth learning of the Python import mechanism
When I was learning Python, I basically skimmed over how to import modules and packages. The reason for this is not only that the syntax of importing is very simple, but also that at the early stage of learning, you will not be involved in large projects, nor will you be writing your own modules and packages, so you will not encounter any problems here. In the process of using
Python Iterators and Generators
We all know that in Python we can for loop to iterate through a list, tuple or range object. So what is the underlying principle? In understanding Python’s data structures, containers (container), iterable objects (iterator), iterators (iterator), generators (generator), lists/sets/dictionary comprehensions (list, set, dict comprehension), and many other concepts are mixed together to make beginners confused. The relationship between them. container A container is a data structure that organizes multiple
Load Balancing Technology for LVS
LVS is the abbreviation of Linux Virtual Server, which means Linux Virtual Server, a virtual server clustering system. LVS is a free software project initiated by Dr. Wen-Song Zhang, and is mainly used for load balancing of multiple servers. It works at the network layer and can achieve high performance, high availability server clustering technology.
It is cheap and can combine many low performance servers together to form a super server.
Unsafe and ByteBuffer things
Starting with the constructor of DirectBuffer The off-heap memory opened by DirectBuffer is actually allocated through Unsafe, take a look at the constructor of DirectBuffer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 DirectByteBuffer(int cap) { // package-private super(-1, 0, cap, cap); boolean pa = VM.isDirectMemoryPageAligned(); int ps = Bits.pageSize(); long size = Math.max(1L, (long)cap + (pa ?
Running a highly available Kafka cluster on Kubernetes
Apache Kafka is the most popular distributed messaging publish-subscribe system available today. While Kafka is very powerful, it is equally complex and requires a highly available and robust platform to run. In a world where microservices are prevalent and most companies are adopting distributed computing, it is still very advantageous to use Kafka as a core messaging system.
If you run your microservices in a Kubernetes cluster, it makes sense to run a Kafka cluster in Kubernetes to take advantage of its built-in resiliency and high availability, and we can easily interact with Kafka Pods within the cluster using the built-in Kubernetes service discovery.
How to understand Python decorators
Introduction to Decorators A decorator is a high-level Python syntax. It can be used to process a function, method, or class. In Python, we have several ways to process functions and classes. Compared to other ways, decorator syntax is simple and the code is highly readable. As a result, decorators have a wide range of applications in Python projects. Decorators are often used in scenarios with tangential requirements, some classic
Redis Large Cluster Scaling Performance Optimization Practices
Background In the existing network environment, some businesses using Redis clusters often need to perform node expansion operations as their business volume rises. I have previously learned that after some operations and maintenance students expanded Redis clusters with a large number of nodes, the business side reported a decrease in cluster performance, as evidenced by a significant increase in access latency. Some businesses are sensitive to Redis cluster access latency,
How to hot load jars for Spring Boot to implement dynamic plugins?
Background Dynamic plug-in programming is a cool thing to achieve decoupling of business functions for easy maintenance, in addition to enhance scalability can be extended at any time without stopping the server, but also has a very good openness in addition to their own R & D staff can develop features, but also to accept third-party developers in accordance with the specifications of the development of plug-ins.
The common implementation of dynamic plug-ins are SPI, OSGI and other solutions, which cannot be injected into the main program’s bean objects in the plug-in because they are not managed by Spring IOC.
Python GUI framework PyQt5
There is not really much software that uses Python to develop graphical interfaces. Compared to GUI interfaces, probably Web way applications are more popular. But for other programming languages like me you such as C# or WPF may not be a good tool. Common GUI frameworks PyQt5: Qt is a cross-platform C++ GUI library. QT was once owned by Nokia and then sold to Digia, a Finnish software company. Oyj.
Pandas read and export Excel, CSV files
When you use Pandas to process data, it is common to read data from Excel or CSV files, and sometimes you need to export the processed data to Excel or CSV files. Today, we will learn how to read and export common Pandas files.
Loading Excel files In Pandas, the Excel file reading method is: pd.read_excel(). The specific passable parameters are.
1 pandas.read_excel(io, sheet_name=0, header=0, names=None, index_col=None, usecols=None, squeeze=False, dtype=None, engine=None, converters=None, true_values=None, false_values=None, skiprows=None, nrows=None, na_values=None, parse_dates=False, date_parser=None, thousands=None, comment=None, skipfooter=0, convert_float=True, **kwds) Where.
TypeScript Enumeration Guide
Enumerations are data types that are supported by TypeScript. Enumerations allow you to define a set of named constants. Use them to more easily document intent or create a different set of cases. Mostly used in object-oriented programming languages such as Java and C#, enumerations are now also available in TypeScript. They are one of the few features of TypeScript that is not a type-level extension of JavaScript. Next I
Golang - About Pointers and Performance
A pointer is an address value that points to the start of an area of memory. So you need to have a good knowledge of computer composition principles. Generally speaking, it is important to maintain a deep memory of what is told in this course and then accumulate it day by day to really reach an understanding.
The concept of a pointer in a high-level language is not fundamentally different from a pointer on a low-level interface.