Linked Questions
74 questions linked to/from Selecting multiple columns in a Pandas dataframe
19
votes
1
answer
81k
views
Print sample set of columns from dataframe in Pandas? [duplicate]
How do you print (in the terminal) a subset of columns from a pandas dataframe?
I don't want to remove any columns from the dataframe; I just want to see a few columns in the terminal to get an idea ...
21
votes
1
answer
8k
views
Pandas Pivot Table manually sort columns [duplicate]
For a given data frame:
UUT testa testb testc testd
DateTime
2017-11-21 18:47:29 1.0 1.0 1.0 3.0
2017-11-21 18:47:30 1.0 2.0 1....
5
votes
1
answer
22k
views
How to apply a function to multiple columns in Pandas [duplicate]
I have a bunch of columns which requires cleaning in Pandas. I've written a function which does that cleaning. I'm not sure how to apply the same function to many columns. Here is what I'm trying:
df[...
6
votes
1
answer
13k
views
How to choose specific columns in a dataframe? [duplicate]
I have a dataframe with 25 columns and an array([ 2, 4, 8, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 22, 23], dtype=int64). I want to choose some specific columns from the dataframe whose indices are ...
-1
votes
1
answer
2k
views
How to create variable list of list of tuples from selected columns in dataframe? [duplicate]
I have df that looks like this:
col1 col2 col3 col4
1 0 1 0
1 0 1 0
1 0 1 0
1 0 1 0
1 ...
1
vote
2
answers
5k
views
Fetch corresponding row value on match column name in pandas [duplicate]
I have a dataframe with many columns and one row, and need to get the column headers for every time that a specific value appears. For example:
Date c1 col2 col3 col4 col5 ...
-3
votes
1
answer
2k
views
how to get desired row and with column names in pandas dataframe? [duplicate]
following is a preview of a marketing dataframe. Complete the code to get desired output
id views clicks
a 1 1000 300
b 2 1200 800
c 3 800 200
output
views clicks
a 1000 ...
1
vote
1
answer
2k
views
Plot transposed dataframe - how to access first column? [duplicate]
I want to plot a linear distribution with the following data (Employee, and days for months(1 for January and so on. To get the data into the right form, I transpose it. But I don't know how to access ...
1
vote
1
answer
604
views
Get data frame for a list of column names [duplicate]
I have a simple pandas DataFrame instance defined as follows:
import pandas as pd
timestamps = [1, 2, 3]
is_events_1 = [False, True, True]
is_events_2 = [True, False, True]
is_censored = [False, True,...
1
vote
1
answer
518
views
Pandas KeyError while adding more than one column from another DataFrame [duplicate]
I got this huge csv with backlog data. I want to take some columns from it and add them to another DataFrame. Looks like this:
Backlog = r'C:\Users\Desktop\personalized reports\Backlog Case\...
0
votes
0
answers
356
views
df.melt() a certain number of variables at a time [duplicate]
I have a spreadsheet with hundreds of variables, that I need to visualize. To do so I'm using df.melt() to convert the dataset to long format. Which is working well to visualize all the variables in ...
2
votes
2
answers
218
views
Apply Same Condition to Multiple Columns [duplicate]
I have a dataframe with 15 separate ICD columns(ICD1 to ICD15) and want to create a variable "Encep" (0/1), when the digits "323" appear in any of the 15 ICD columns.
The dataframe itself contains ...
0
votes
0
answers
235
views
dataframe slicing with loc [duplicate]
I have a datframe,df
2.3.6 16.3.9 9.2.7 43.5.2 4.5.6 45.2.1
August 2 1 8 3 10 3
September 7 0 7 3 ...
1
vote
1
answer
214
views
Reference dictionary values [duplicate]
I have a dataframe, df with columns headers A, B , C, D
can I reference these headers from this dictionary?
dic={'key1':['A','B'],
key2: [C,D]}
df[key1[0]]
giving the output of just column A?
A
...
0
votes
0
answers
171
views
Comparing specific columns in 2 Excel Files with Pandas: How to select specific/ range of columns? [duplicate]
My problem is as follows. Using the pd.ExcelFile methodology I've figured out how to read and parse the relevant Excel files and Sheets that I want to compare. However, while both have similar data in ...