logo_learn_stats

Pandas: Learn how to Learn Explicit Columns from Excel Record

Posted on
banner 336x280

You’ll be able to usefulness please see forms to learn particular columns from an Excel record right into a pandas DataFrame:

Form 1: Learn Explicit Columns

banner 468x60
df = pd.read_excel('my_data.xlsx', usecols="A, C")

Form 2: Learn a Dimension of Columns

df = pd.read_excel('my_data.xlsx', usecols="A:C") 

Form 3: Learn More than one Levels of Columns

df = pd.read_excel('my_data.xlsx', usecols="A:C, F, G:J") 

Refer to examples display methods to usefulness each and every form in follow with please see Excel record referred to as player_data.xlsx:

Instance 1: Learn Explicit Columns

We will usefulness please see code to import the information in columns A and C from the Excel record:

import pandas as pd

#import columns A and C from Excel record
df = pd.read_excel('player_data.xlsx', usecols="A, C")

#view DataFrame
print(df)

  crew  rebounds
0    A         8
1    B        12
2    C         4
3    D         4
4    E         6
5    F         7

Understand that most effective the information from columns A and C within the Excel record had been imported.

Instance 2: Learn a Dimension of Columns

We will usefulness please see code to import the information in columns A via C from the Excel record:

import pandas as pd

#import columns A via C from Excel record
df = pd.read_excel('player_data.xlsx', usecols="A:C")

#view DataFrame
print(df)

  crew  issues  rebounds
0    A      24         8
1    B      20        12
2    C      15         4
3    D      19         4
4    E      32         6
5    F      13         7

Understand that most effective the information from columns A via C within the Excel record had been imported.

Instance 3: Learn More than one Levels of Columns

We will usefulness please see code to import the information in columns A via C and column D from the Excel record:

import pandas as pd

#import columns A via C from Excel record
df = pd.read_excel('player_data.xlsx', usecols="A:C, D")

#view DataFrame
print(df)

  crew  issues  rebounds  assists
0    A      24         8        5
1    B      20        12        3
2    C      15         4        7
3    D      19         4        8
4    E      32         6        8
5    F      13         7        9

Understand that the information from columns A via C and column D within the Excel record had been imported.

Observe: You’ll be able to to find your complete documentation for the pandas read_excel() serve as right here.

Backup Assets

Refer to tutorials provide an explanation for methods to carry out alternative regular duties in pandas:

Pandas: Learn how to Skip Rows when Studying Excel Record
Pandas: Learn how to Specify dtypes when Uploading Excel Record
Pandas: Learn how to Mix More than one Excel Sheets

banner 336x280

Leave a Reply

Your email address will not be published. Required fields are marked *