How to re-order and rename pandas pivot?

I am trying to re-order the columns exported to my excel. It is currently ordered alphabetically. I want Sales Order Net Value, Billed Net Value and then Open Amount? Is there a way to rename the columns just for the excel? How can I rename All to ...
more »

2017-03-20 21:03 (1) Answers

invalid type comparison error

I have been using this code: df = df[df['A']>0] df.loc[(df['A']<0), 'A'] = df['A'].median() I am getting error invalid type comparison. I would like to replace all values in the column A that are negative with median, mean or drop them. An...
more »

2017-03-20 15:03 (1) Answers

Calculate column value based on 2 dataframes

I have 2 data frames, one has a Date column and other has 2 Dates column. Both has same index which is an ID. My first question is to be sure if I am right, if I want to compute on both dataframes, the rows that has the same index will compute toget...
more »

2017-03-20 11:03 (1) Answers

Transform list to dataframe efficiently

I have a list of images and I want to get all the pixels of each image in one DataFrame column and the number of the image into another column. I am trying to do it with plotDF = DataFrame() plotData = [np.array([[1,2,1],[1,1,2],[4,2,1]]), np.array(...
more »

2017-03-20 11:03 (1) Answers

Sequentially read huge CSV file in python

I have a 10gb CSV file that contains some information that I need to use. As I have limited memory on my PC, I can not read all the file in memory in one single batch. Instead, I would like to iteratively read only some rows of this file. Say that ...
more »

2017-03-20 11:03 (2) Answers

Pandas - Counting the number of days for group by

I want to count the number of days after grouping by 2 columns: groups = df.groupby([df.col1,df.col2]) Now i want to count the number of days relevant for each group: result = groups['date_time'] I'm using something similar wh...
more »

2017-03-20 09:03 (1) Answers

Converting row in timeseries data to column

Suppose that I have a timeseries like In [41]: df = pd.DataFrame(dict(names=list('abcaabcabbcc'), vals=np.random.randint(0, 10, 12)), index ...: =pd.date_range('2017-03-01', periods=12)) In [42]: df Out[42]: names vals 2017-03-01 ...
more »

2017-03-19 19:03 (2) Answers

pandas dropping columns based on column name

all Let's say there is a df with some column names - in my case the names are numeric values. For example, column named 1000, 1001, etc. I need to drop everything that doesn't pass a certain filter test - in my case, all columns with names less th...
more »

2017-03-19 16:03 (3) Answers

Separating row values to a new column

I have this kind of pandas dataframe output, columns are at the top row: Date, Team1, Team2, Map, Event 17/3/17, Misfits 16, Cloud9 4, overpass, Pro League 17/3/17, TyLoo 16, Born Of Fire 4, cache, Pro League 17/3/17, Liquid 8, Renegades 16, cbble, ...
more »

2017-03-18 22:03 (3) Answers

Selection with pandas multiIndexed dataframe

I have a multiIndexed dataframe that looks like this: df.head(): How can I select all of the rows where the first index == "particular school name" and all of second indices, where the Month column == "Jan"? I haven't worked with multiIndexed d...
more »

2017-03-18 15:03 (1) Answers