Linked Questions

13 votes
1 answer
32k views

Pandas Column names to list - correct method [duplicate]

I cannot find any resources about wether one of the following three methods for getting a list of column names is preferred over the others. The first and simplest, seems to work with my current ...
Giannis's user avatar
  • 5,536
5 votes
1 answer
14k views

displaying columns names of dataFrame in python [duplicate]

I have an xlsx file having about 100 columns. When I use df.columns function then it display some of the first and some last columns but not all of them. I want to display(print) all of the column ...
Khan's user avatar
  • 107
14 votes
0 answers
11k views

get column names from csv file using pandas [duplicate]

I am using pandas to read a heavy csv file as below import pandas csv_file_path = "/Users/import.csv" csv_data = pandas.read_csv(csv_file_path, names=data_mapping_field_values) When i use csv_data....
Shiva Krishna Bavandla's user avatar
-1 votes
2 answers
4k views

Pandas Dataframe keys to array [duplicate]

I want an array of values from dataframe.keys() method. But it returns an Index object, that have the header values array as a member. But I want only that array, no other details. header_values=...
DevLoverUmar's user avatar
  • 14.3k
3 votes
2 answers
1k views

Is there a way to select only column labels using Pyhon Pandas library without any rows? [duplicate]

This might be a silly question to ask, however, it is for a specific task in a multi-step process to clean up some data. Basically, each column label is a location represented as a series of long ...
some_name_some_numbers's user avatar
308 votes
8 answers
598k views

How do I convert a Pandas series or index to a NumPy array? [duplicate]

How can I get the index or column of a DataFrame as a NumPy array or Python list?
ericmjl's user avatar
  • 14.9k
44 votes
3 answers
97k views

Convert multiple columns to string in pandas dataframe

I have a pandas data frame with different data types. I want to convert more than one column in the data frame to string type. I have individually done for each column but want to know if there is an ...
Sayonti 's user avatar
  • 1,186
15 votes
6 answers
48k views

pandas column names to list

According to this thread: SO: Column names to list It should be straightforward to do convert the column names to a list. But if i do: df.columns.tolist() I do get: [u'q_igg', u'q_hcp', u'c_igg', u'...
Moritz's user avatar
  • 5,448
8 votes
2 answers
16k views

Is pandas.DataFrame.columns.values.tolist() the same as pandas.DataFrame.columns.tolist()

We have both code popping up in our codebase pandas.DataFrame.columns.values.tolist() pandas.DataFrame.columns.tolist() Are these always identical? I'm not sure why the values variant pops up in the ...
jxramos's user avatar
  • 8,412
1 vote
5 answers
3k views

Is it possible to put the Pandas dataframe column header as a footer instead?

I have a numpy array, and for simplicity sake it is empty. The dimensions are 8x12 . I have my row and column headers defined. column = [_ for _ in 'ABCDEFGH'] row = list(range(12, 0, -1)) self.board ...
shelbaz's user avatar
  • 97
12 votes
1 answer
3k views

sckit-learn fit() leads to error after normalising the data

I have been trying this: Create X features and y dependent from a dataset Split the dataset Normalise the data Train using SVR from Scikit-learn Here is the code using a pandas dataframe filled with ...
azuric's user avatar
  • 2,859
0 votes
3 answers
2k views

How do you suppress a warning/error in Python and or Cloud9 IDE?

I am using the Cloud9 IDE and have created a Python project. However, I keep getting the error in my editor on one line, which is not an error when i run it, which says: Instance of 'dict' has no '...
WJA's user avatar
  • 7,054
3 votes
1 answer
3k views

exporting feature importance to csv from random forest

Hi I would like to create a .csv with 2 columns: the feature importance of a random forest model and the name of that feature. And to be sure that the match between numeric value and variable name is ...
progster's user avatar
  • 937
1 vote
1 answer
3k views

Get column names from pandas DataFrame in format dtype:object

I have a similar doubt to the one in the mentioned link. Instead of returning column names in a list, I want column names in the format dtype:object. For example, A B C D Name:x,dtype:object I am ...
cliff's user avatar
  • 45
0 votes
1 answer
1k views

Dynamically rename column name in python

I have a dataframe which will automatically generate multiple columns like result1, result2, result3, result4 etc. I want to rename the last result i.e result4 in this case. The number of columns will ...
Chetan P's user avatar
  • 197

15 30 50 per page