Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
lists
#11
I'd use Pandas, largely as it is simple to select data according to your preference.
import pandas as pd

sky = [[20,20,150,200,230],[21,20,0,0,0],[22,20,100,110,90],[23,20,200,220,220],[24,20,210,210,210]]
colnames = ['x','y','red','green','blue']
df = pd.DataFrame(sky,columns=colnames)
df.head()
Output:
x y red green blue 0 20 20 150 200 230 1 21 20 0 0 0 2 22 20 100 110 90 3 23 20 200 220 220 4 24 20 210 210 210
This sets up the dataframe with columns for x and y coordinates and columns for the RGB readings of the pixels. Selecting bright ones is then simple as
dfbright = df[df.red+df.green+df.blue > 600]
dfbright.head()
Output:
x y red green blue 3 23 20 200 220 220 4 24 20 210 210 210
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,312 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 3,190 Mar-20-2019, 08:01 PM
Last Post: stillsen

Forum Jump:

User Panel Messages

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