Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 sort values of a column pandas
#1
Hi,

I'm trying to sort a df looking like this into 2 dfs. Any help! Thks

              A                          pos                  neg
index                         index                index  
01.01.19      0    -> new     01.01.19   0         03.01.19   -1
02.01.19      1               02.01.19   1         12.01.19   -2
03.01.19     -1               14.01.19   3         
12.01.19     -2               31.01.19   1
14.01.19      3               
31.01.19      1        
Thks
Quote
#2
D = pd.read_csv('sort.csv')
E = pd.DataFrame(D)
print(E[E['A'] < 0])
print(E[E['A'] > 0])
Quote
#3
(Oct-21-2019, 04:24 PM)aankrose Wrote:
D = pd.read_csv('sort.csv')
E = pd.DataFrame(D)
print(E[E['A'] < 0])
print(E[E['A'] > 0])

Thks aankrose ...
I was trying to make thnings complicated like this
for col in df:
   if df['col'] > 0:
      df['pos'] = df['col']
   else:
      df['neg'] = df['col']
return df 

Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Pandas copying wrong values vmarg 2 117 Jan-06-2020, 09:45 AM
Last Post: vmarg
  itertuples, new column, datetime, pandas karlito 6 347 Nov-29-2019, 11:07 AM
Last Post: karlito
  Dropping a column from pandas dataframe marco_ita 6 1,703 Sep-07-2019, 08:36 AM
Last Post: marco_ita
  How to drop column in pandas SriMekala 3 618 Aug-26-2019, 06:36 PM
Last Post: snippsat
  Pandas Import CSV count between numerical values within 1 Column ptaylor520 3 335 Jul-16-2019, 08:13 AM
Last Post: ptaylor520
  How to use the excel filename as a value to populate new column, using Pandas? Dequanharrison 5 776 Jun-26-2019, 11:11 PM
Last Post: Dequanharrison
  pandas change row value an existing column with conditionals Gigux 1 505 Jun-22-2019, 08:04 PM
Last Post: Gigux
  Custom timeinterval converted to hourly values using Pandas? SinPy 1 718 Jun-07-2019, 05:06 AM
Last Post: heiner55
  How to delete column if entire column values are "nan" Sri 4 750 Apr-13-2019, 12:16 PM
Last Post: Sri
  Text to column pandas ms5573 0 684 Aug-25-2018, 08:18 PM
Last Post: ms5573

Forum Jump:


Users browsing this thread: 1 Guest(s)