[PYTHON] I want to make the second line the column name in pandas

I was having trouble reading data with pandas

When I read the Excel sheet, there was an obstructive character in the first line, so the column name was just "Unnamed ...".

To get as data from the second line

  1. Read the data first
  2. Change the column name of the data It seems that processing such as is necessary, Darui. ..

As soon as I thought, I found the Qiita article of my predecessor. The following is an excerpt from that article.


Task

image.png

solution

Use pandas's skiprows to skip the first unwanted part and load the Excel file.


df = pd.read_excel(excel_file_path, skiprows=2, header=[0, 1])

Recommended Posts

I want to make the second line the column name in pandas
I want to get the file name, line number, and function name in Python 3.4
I want to make the Dictionary type in the List unique
I want to display the progress in Python!
I want to see the file name from DataLoader
I want to write in Python! (3) Utilize the mock
I want to use the R dataset in python
I want to save the photos sent by LINE to S3
Put the lists together in pandas to make a DataFrame
I tried to summarize the code often used in Pandas
I want to align the significant figures in the Numpy array
I want to make input () a nice complement in python
I didn't want to write the AWS key in the program
I want to do ○○ with Pandas
I want to see the graph in 3D! I can make such a dream come true.
I want to get the name of the function / method being executed
I want to know the weather with LINE bot feat.Heroku + Python
[Linux] I want to know the date when the user logged in
LINEbot development, I want to check the operation in the local environment
I want to pass the G test in one month Day 1
I want to know the population of each country in the world.
Make the line breaks visible in journalctrl
I want to print in a comprehension
I want to display the progress bar
I want to make an automation program!
I want to embed Matplotlib in PySimpleGUI
I want to handle the rhyme part2
I want to handle the rhyme part5
I want to handle the rhyme part4
I want to change the color by clicking the scatter point in matplotlib
How to get a specific column name and index name in pandas DataFrame
[C language] I want to generate random numbers in the specified range
I want to batch convert the result of "string" .split () in Python
I want to explain the abstract class (ABCmeta) of Python in detail.
I want to sort a list in the order of other lists
I want to use the Django Debug Toolbar in my Ajax application
The file name was bad in Python and I was addicted to import
I want to leave an arbitrary command in the command history of Shell
A note I looked up to make a command line tool in Python
I want to make matplotlib a dark theme
I want to do Dunnett's test in Python
I want to pin Datetime.now in Django tests
12. Save the first column in col1.txt and the second column in col2.txt
I want to create a window in Python
I want to make a game with Python
I want to store DB information in list
I want to merge nested dicts in Python
I want to make fits from my head
I want to make C ++ code from Python code!
I want to customize the appearance of zabbix
I want to use the activation function Mish
I want to visualize where and how many people are in the factory
[Python] I want to know the variables in the function when an error occurs!
[LINE Messaging API] I want to send a message from the program to everyone's LINE
I want to use Python in the environment of pyenv + pipenv on Windows 10
[Django memo] I want to set the login user information in the form in advance
Handle CSV that contains the element you want to parse in the file name
I want to make a music player and file music at the same time
I want to set a life cycle in the task definition of ECS
I want to add silence to the beginning of a wav file for 1 second
I want to see a list of WebDAV files in the Requests module