๐Ÿ“Š[DataCamp] Pandas : Slicing and subsetting with .loc and .iloc, Working with pivot tables

2020. 9. 6. 02:01ใ†Learning archive/Data Science

 

Slicing lets you select consecutive elements of an object using first:last syntax. DataFrames can be sliced by index values, or by row/column number; we'll start with the first case. This involves slicing inside the .loc[] method.

 

 

 

 

 

๐Ÿ“Œ Data Frame์€ Slice ์ „์— Sort the index! 

 

๐Ÿ“Œ Outer index level .loc["" : ""]

 

๐Ÿ“Œ inner index levels : ํŠœํ”Œ๋กœ Sliceํ•˜๊ธฐ 

๐Ÿ“ŒColumns ์Šฌ๋ผ์ด์‹ฑ 

 

 

 

 

๐Ÿ“Œ ํ–‰๊ณผ ์—ด์„ ๋ชจ๋‘ sliceํ•˜๊ธฐ 

๐Ÿ“Œ Practice : Subsetting rows, cols, both 

 

 

 

 

 

 

๐Ÿ“ŒWorking with pivot tables

 

 

 

 

๐Ÿ“ŒReview : a pivot table 

 

 

Rideat to subsetting pivot table 

 

๐Ÿ“Œ.mean(axis="")