C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Pandas DataFrame.query()For analyzing the data, we need a lot of filtering operations. Pandas provide a query() method to filter the DataFrame. It offers a simple way of making the selection and also capable of simplifying the task of index-based selection. SyntaxDataFrame.query(expr, inplace=False, **kwargs) Parameters
ReturnIt returns a DataFrame that results from the query expression. Note: This method only works if the column name doesn't have any empty spaces. You can replace the spaces in column names with '_'Example1info = pd.DataFrame({'X': range(1, 6), 'Y': range(10, 0, -2), 'Z Z': range(10, 5, -1)}) info info.query('X > Y') info[info.X > info.Y] info[info.Y == info['Z Z']] Output X Y Z Z 0 1 10 10
Next TopicDataFrame.rename()
|