Python Forum
How to map dataframe to list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to map dataframe to list
#2
You definitely should avoid using pure Python loops when working with Pandas/NumPy etc.
Not sure if this is an optimal solution, especially in case of big data2 arrays; However, it is working one:

df['id'] = sum(df.Name.str.findall("|".join(data2)).map(lambda x: x if x else [pd.np.nan]).tolist(), [])
Note: That in future versions of Pandas pd.np will be deprecated; you probably need to import numpy directly.
Reply


Messages In This Thread
How to map dataframe to list - by Mekala - Aug-07-2020, 05:48 PM
RE: How to map dataframe to list - by scidam - Aug-09-2020, 12:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  function returns dataframe as list harum 2 3,273 Aug-13-2022, 08:27 PM
Last Post: rob101
  Using .append() with list vs dataframe Mark17 7 16,041 Jun-12-2022, 06:54 PM
Last Post: Mark17
  List of dataframe values beginning with x,y or z glidecode 3 2,944 Nov-08-2021, 10:16 PM
Last Post: glidecode
  Reading data to python: turn into list or dataframe hhchenfx 2 7,091 Jun-01-2021, 10:28 AM
Last Post: Larz60+
  convert list to five columns dataframe in sequence tonycat 2 3,388 Sep-29-2020, 06:47 AM
Last Post: tonycat
  Get Value from List to Show in DataFrame Column ahmedwaqas92 1 2,540 Jun-22-2020, 08:24 AM
Last Post: ahmedwaqas92
  Inserting a python list into a dataframe column wise mahmoud899 0 4,919 Mar-04-2019, 11:44 PM
Last Post: mahmoud899
  Break Up Tuple List Into A Dataframe? digitalmatic7 2 5,300 Apr-26-2018, 05:29 PM
Last Post: digitalmatic7

Forum Jump:

User Panel Messages

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