In the original article, I did not include any information about using pandas DataFramefilterto select columns. I think this mainly becausefiltersounds like it should be used to filter data not column names. Fortunately youcanuse pandasfilterto select columns and it is very useful....
Here, theDataFrame.loc()property will read the sliced index, colon (:) means starting from the first column,DataFrame.columnswill return all the columns of a DataFrame and define a specified column name after the conditional operator (!=) will return all the column names except the one which...
DF_obj.loc[['row 2','row 5'],['column 5','column 2']] Data slicing You can use slicing to select and return a slice of several values from a data set. Slicing uses index values so you can use the same square brackets when doing data slicing. How slicing differs, however, is t...
In [1]: dates = pd.date_range('1/1/2000', periods=8) In [2]: df = pd.DataFrame(np.random.randn(8, 4), index=dates, columns=['A', 'B', 'C', 'D']) In [3]: df Out[3]: A B C D 2000-01-01 0.469112 -0.282863 -1.509059 -1.135632 2000-01-02 1.212112 -0.173215 0.11...