In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "skills in the use of Pandas and Docker". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Pandas reads headless CSV
We know that CSV usually looks like this:
Where the name,salary,work in the first line is called the header of CSV. Normally, CSV has a header, so it's very convenient when we use pandas to read CSV:
Import pandas as pd df = pd.read_csv ('example.csv') print (df)
The running effect is shown in the following figure:
Sometimes, however, some special CSV files may not have headers. For example, they might look like this:
In this case, if you read directly using pandas, the first row of data becomes a header, as shown in the following figure. But this is obviously not what I want:
In order to solve this problem, there are two solutions. The first method is to open the CSV file with a text editor, manually add the header, and save it. And then read it with pandas.
The second way is to add a parameter, names, when pandas reads, whose value is a list, or header:
Import pandas as pd df = pd.read_csv ('example.csv', names= [' name', 'salary',' work']) print (df)
The running effect is shown in the following figure:
Docker build increases apt-get Speed
When using Docker to build Ubuntu-based images in China, official sources are used by default. For well-known reasons, the speed of building can be slow. If you are directly operating the Ubuntu of the host, we can use vim or graphical interface to modify the source and use the Ali source to improve speed.
What should I do if it is in Docker? We can then use Linux text processing sed, one of the three Musketeers, to modify the source file non-interactively.
Add the following two lines to Docker:
RUN sed-is @ / archive.ubuntu.com/@/mirrors.aliyun.com/@g / etc/apt/sources.list RUN apt-get clea
Its purpose is to replace all archive.ubuntu.com in the / etc/apt/sources.list file with mirrors.aliyun.com. To increase the speed.
This is the end of the introduction to "Pandas and Docker skills". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.