Concating pandas dataframe

I have following dataframe: df1 = pd.DataFrame.from_dict({'A':[3,5,1,7], 'DateTime' : pd.date_range("11:00", "14:00", freq="60min")}).set_index('DateTime') df2 = pd.DataFrame.from_dict({'B':[13,15,1,17], 'DateTime' : pd.date_range("12:00", "15:00"...
more »

2017-04-19 21:04 (1) Answers

Apply function to elements of dataframe

Suppose I have the following dataframe df 1 3 Scenario1 0.001 0.05 Scenario2 0.003 0.01 Scenario3 0.001 0.042 Scenario4 0.09 0.006 Scenario5 0.02 0.04 Suppose these are interest rates and periods and I want to c...
more »

2017-04-19 11:04 (2) Answers

Create label for two column in pandas

I have a pandas dataframe with two column of data. Now i want to make a label for two column, like the picture bellow: Because two column donot have the same value so cant use groupby. I just only want add the label AAA like that. So, how to do it?...
more »

2017-04-19 09:04 (2) Answers

Pandas find max stable interval

I implemented some script using pandas, but I´m not sure if it is the most elegant/fast implementation. (I'm using a for loop...) Suppose you have a y variable (float) vs time What I need to do is create a new column (0 or 1) on the dataframe indi...
more »

2017-04-18 23:04 (2) Answers

How to modify full text of some columns in pandas

I got a fairly big dataframe from a csv in pandas. The problem is that on some columns I get strings of text which I would like to isolate the last character to turn it into integers. I found a solution, but I am fairly sure it's not the most effic...
more »

2017-04-18 23:04 (2) Answers

Python Pandas, apply function

I am trying to use apply to avoid an iterrows() iterator in a function: However that pandas method is poorly documented and I can't find example on how to use it, except for the lame .apply(sq.rt) in the documentation... No example on how to use arg...
more »

2017-04-18 21:04 (4) Answers

Fbprophet quickstart example - KeyError: 'ds'

Following the quickstart example & having a problem when trying to fit the model at: m.fit(df); The terminal shows: Traceback (most recent call last): File "/home/cartier/miniconda2/envs/prophet/lib/python3.6/site-packages/pandas/indexes/base...
more »

2017-04-18 18:04 (1) Answers

Comparison by category in Pandas

I have a dataframe roughly like this: category value 1 A 2 2 B 5 3 A 3 4 A 2 5 B 1 Now I want to add a column that tells me if the current value is above or below the medium in i...
more »

2017-04-18 16:04 (1) Answers

Python Pandas reordering table

I have a dataframe in pandas that looks like this: ID TIME A B C 1 ddmmyy value_of_A1 value_of_B1 value_of_C1 2 ddmmyy value_of_A2 value_of_B2 value_of_C2 3 ddmmyy value_of_A3 value_of_B...
more »

2017-04-18 15:04 (2) Answers

multi-numpy array from dataframe

I have 5 Pandas DataFrames, its 5 classes of objects in 80,00 images and the coordinates of the objects. Basically, there is more than one class in each image class 1: image_id x y image_0 4835 106 image_0 2609 309 image_0 ...
more »

2017-04-18 05:04 (1) Answers

Pandas split a dataframe column

I have the following dataframe where I want to split the Col2 into multiple columns: Input DataFrame: >>> mydf= pd.DataFrame({'Col1':['AA','AB','AAC'], 'Col2':['AN||Ind(0.9)','LN||RED(8.9)','RN||RED(9.8)'], 'Col3':['log1','log2','log3']}) ...
more »

2017-04-17 22:04 (3) Answers