pandas loc on str lower for column comparison

Sayth Renshaw flebber.crue at gmail.com
Wed Sep 4 21:46:15 EDT 2019


On Sunday, 1 September 2019 10:48:54 UTC+10, Sayth Renshaw  wrote:
> I've created a share doc same structure anon data from my google drive.
> 
> https://drive.google.com/file/d/0B28JfFTPNr_lckxQRnFTRF9UTEFYRUVqRWxCNVd1VEZhcVNr/view?usp=sharing
> 
> Sayth

I tried creating the df1 dataframe by using iloc instead of loc to avoid any column naming issues.

So i created a list of integers for iloc representing the columns in current example.

df1 = df.iloc[[0,1,5,6,7]] 

However, I ust be misunderstanding the docs https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.iloc.html#pandas.DataFrame.iloc
Allowed inputs are:

An integer, e.g. 5.
A list or array of integers, e.g. [4, 3, 0].

Because while it works I appear to grab all columns 13 when I requested 5.
	UID	Name	FTE	Agent ID	Current Leader	New Leader	Current Team	New Team	Current Site	New Site	Unnamed: 10	Unnamed: 11	Unnamed: 12 

How do I misunderstand iloc?

Thanks,
Sayth



More information about the Python-list mailing list