You are almost there, actually just use flatten
instead of reduce
to unnest the array (instead of unnesting the list), and chain operations to have a one liner:
df.loc[df.n == "d", ['a','b']].values.flatten().tolist()
#[4, 6]
Related Contents:
- Renaming column names in Pandas
- Filter pandas DataFrame by substring criteria
- How to filter Pandas dataframe using ‘in’ and ‘not in’ like in SQL
- How to check if a column exists in Pandas
- How to reversibly store and load a Pandas dataframe to/from disk
- Convert Pandas Column to DateTime
- Keep only date part when using pandas.to_datetime
- Plot correlation matrix using pandas
- Rename specific column(s) in pandas
- Pandas DataFrame: replace all values in a column, based on condition
- Find column whose name contains a specific string
- JSON to pandas DataFrame
- How to plot multiple dataframes in subplots
- Check if a value exists in pandas dataframe index
- ImportError: No module named dateutil.parser
- How can I make pandas dataframe column headers all lowercase?
- Why were pandas merges in python faster than data.table merges in R in 2012?
- Python pandas: fill a dataframe row by row
- Convert row to column header for Pandas DataFrame,
- Drop rows with all zeros in pandas data frame
- Creating a new column based on if-elif-else condition
- How to save a new sheet in an existing excel file, using Pandas?
- Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support
- ImportError: No module named pandas
- How to delete all columns in DataFrame except certain ones?
- Keep selected column as DataFrame instead of Series
- sorting by a custom list in pandas
- Pandas concat: ValueError: Shape of passed values is blah, indices imply blah2
- Get first element of Series without knowing the index [duplicate]
- Can I assign a reset index a name?
- start index at 1 for Pandas DataFrame
- Pandas: create new column in df with random integers from range
- Keep other columns when doing groupby
- Pandas: Subtracting two date columns and the result being an integer
- Pandas: ValueError: cannot convert float NaN to integer
- Indexing Pandas data frames: integer rows, named columns
- How to write DataFrame to postgres table
- Counting non zero values in each column of a DataFrame in python
- Access index in pandas.Series.apply
- How to merge two dataframes side-by-side?
- FailedPreconditionError: Attempting to use uninitialized in Tensorflow
- Python generating a list of dates between two dates
- Pandas – combine column values into a list in a new column
- Computing diffs within groups of a dataframe
- Extracting the first day of month of a datetime type column in pandas
- Pandas converting row with unix timestamp (in milliseconds) to datetime
- Why use pandas.assign rather than simply initialize new column?
- merging 2 dataframes vertically [duplicate]
- Calculate new column as the mean of other columns in pandas [duplicate]
- Converting pandas.tslib.Timestamp to datetime python