1. Extracting and transforming data - upalr/Python-camp GitHub Wiki
1 Indexing DataFrames
1.1 A simple Dataframe
1.2 Indexing using square brackets
1.3 Using column attribute and row label
1.4 Using the .loc accessor
1.5 Using the .iloc accessor
1.6 Selecting only some columns
2 Slicing DataFrames
Please watch this from the link as you are already familiar with this slicing stuffs.
2.1 Exaple: 1 : Slicing rows
Slice the row labels 'Potter' to 'Perry' in reverse order. To do this for hypothetical row labels 'a' and 'b', you could use a stepsize of -1 like so: df.loc['b':'a':-1].
3 Filtering dataframes
3.1 Creating a Boolean series
3.2 Filtering with a Boolean Series
3.3 Combining filters
3.4 Dataframes with zeros and NaNs
3.5 Select columns with all non nonzeros
Excludes the baconcolumn because it has zero entries.
3.6 Select columns with any nonzeros
In this case, there is no columns with all zeroes so all off df2 is returned.
3.7 Select columns with any NaNs
Combining any() and isnull() returns any columns that have a NaN value.
3.8 Select columns without NaNs
We might want all columns where all column is present.
3.9 Drop rows with any NaNs
3.10 Filtering a column based on another
3.11 Modifying a column based on another
3.12 Example 1 : Filtering using NaNs
4 Transforming DataFrames methods
4.1 Dataframe vectorized methods
4.2 NumPy vectorized functions
4.3 Plain python functions (1)
4.4 Plain python functions (2)
4.5 Storing a transformation
4.6 The dataframe index
4.7 Working with string values (1)
4.8 Working with string values (2)
4.9 defining columns using other columns
4.10 Example 2: Using apply() to transform a column
Using apply() to transform a column