Python Forum
List of dataframe values beginning with x,y or z
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
List of dataframe values beginning with x,y or z
#4
I figured out the problem!

It is described here: https://cumsum.wordpress.com/2021/05/05/...type-bool/

Simply, the expression is interpreted with priority to the "|" - so in my example, it will look to see if the first letter is equal to A or equal to the rest of the expression. Hope this makes sense to anyone looking for the same.

I fixed it like this - simply adding two sets of parentheses:

sorted = rawdata[(rawdata['Ticker'].astype(str).str[0] =="A") | (rawdata['Ticker'].astype(str).str[0] =="B")]
Reply


Messages In This Thread
RE: List of dataframe values beginning with x,y or z - by glidecode - Nov-08-2021, 10:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  remove duplicates from dicts with list values wardancer84 27 978 May-27-2024, 04:54 PM
Last Post: wardancer84
  Just beginning dalekeel 2 392 Apr-15-2024, 11:49 AM
Last Post: Pedroski55
  Copying the order of another list with identical values gohanhango 7 1,327 Nov-29-2023, 09:17 PM
Last Post: Pedroski55
  Search Excel File with a list of values huzzug 4 1,406 Nov-03-2023, 05:35 PM
Last Post: huzzug
  Comparing List values to get indexes Edward_ 7 1,378 Jun-09-2023, 04:57 PM
Last Post: deanhystad
  Transposing a dataframe without creating NaN values doug2019 2 1,074 Mar-18-2023, 03:14 PM
Last Post: jefsummers
  Program doesnt return beginning bilisim19 2 1,015 Feb-15-2023, 06:23 PM
Last Post: Larz60+
  Adding values with reduce() function from the list of tuples kinimod 10 2,922 Jan-24-2023, 08:22 AM
Last Post: perfringo
  user input values into list of lists tauros73 3 1,202 Dec-29-2022, 05:54 PM
Last Post: deanhystad
  function returns dataframe as list harum 2 1,571 Aug-13-2022, 08:27 PM
Last Post: rob101

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020