Skip to main content

All Questions

Tagged with
1 vote
1 answer
44 views

Transforming lists in rows dataframe to strings

I have a dataset that has a column that has its values stored in lists. I want to transform the lists into strings, i.e. the values will go from [a, b, c] to "a b c" separated by spaces, in ...
Rafael Morais's user avatar
0 votes
1 answer
624 views

Naming dataframe passing it as argument in a function

I want to know how I can build a function where I can pass the name of the dataframe that I will create as argument. Here I have an example: list1 = [1,2,3] list2 = [4,5,6] def say_hi(list1, list2): ...
D EA's user avatar
  • 17
0 votes
0 answers
23 views

Create dataframe specific lists in a function

I have several datasets. I would like to create a list for each one. Is there a way to do this in some kind of function? As of now I write it one below the other, since the code is quite long I don't ...
hazen23's user avatar
  • 29
0 votes
1 answer
29 views

pandas df creation of list within a function to be used outside the function

I want to create a list of first three values in a column in a df, but this df is created within a function and will be called several times with different input variables. Every time I call this ...
user18334254's user avatar
0 votes
1 answer
2k views

TypeError: unhashable type: 'list' when creating a new column

import pandas as pd data = {'A': [1,2], 'B':[[1,1,1,2,2,4,4,4,4],[5, 4, 8, 1, 1, 1, 3, 2, 4, 2, 2, 2, 1, 1, 1]]} df = pd.DataFrame(data) A B 1 [1, 1, 1, 2, 2, 4, 4, 4, 4] 2 [5, 4, 8, 1, 1, 1, 3, 2, ...
7F_WZ's user avatar
  • 29
0 votes
0 answers
125 views

How to correctly pass a copy of pandas list_of_dataframes to a function?

I have a list of dataframes - df_list = [df1, df2, df3] Pass its copy to a function - def fun(df_l): # code to stop ww3 using the copy of df_l fun(df_list.copy()) Now, this is in relation to a ...
Pranav Joshi's user avatar
0 votes
1 answer
188 views

Create new column with applying a function (TypeError: unhashable type: 'list')

df['identities'] | identities | | --------------------------------------------------------- | | 0 [93, 94, 127, 112, 93, 94, 127, 112, 20, 68, 6.....
7F_WZ's user avatar
  • 29
0 votes
1 answer
63 views

Convert CSV to dictionary of dictionaries

data = {'': '11', 'RecID': '11', 'year': '2020', 'Flugnummer': 'DL67', 'cabin_class': 'economy', 'DEPARTURE_AIRPORT': 'ZRH', 'ARRIVAL_AIRPORT': 'ATL', 'Anzahl Flugsegmente': '1', 'distance': '7652', '...
MisterCoder's user avatar
0 votes
1 answer
257 views

How to check if entries in Pandas DataFrame are in a List using pandas.apply

I have a DataFrame with a column name that includes string data-type. I want to check if entries of this column exist in a Reference list. I tried pandas.apply, but it doesn't work. Sample data: ...
Mohammad's user avatar
  • 1,023
0 votes
2 answers
1k views

define range in pandas column based on define input from list

I have one data frame, wherein I need to apply range in one column, based on the list provided, I am able to achieve results using fixed values but input values will be dynamic in a list format and ...
DD08's user avatar
  • 87
1 vote
1 answer
93 views

I wish to optimize the code using pythonic ways using lambda and pandas

I have the following Dataframe: TEST_NUMBER D1 D10 D50 D90 D99 Q3_15 Q3_10 l-Q3_63 RPM PRODUCT_NO 0 11 4.77 12.7 34.9 93.7 213.90 13.74 5.98 21.44 0.0 BQ0066 1 21 4.43 ...
Prasad's user avatar
  • 65
1 vote
1 answer
136 views

iterating a list and passing results through a function and saving results in a dataframe

I have this list : Peer_List_Members = [1967, 2338, 421, 1275, 2499, 2240, 881, 2719, 2894, 2198, 3120, 3160, 635] I iterate over this list as follows: for x in Peer_List_Members: x = ...
Herman L's user avatar
  • 165
1 vote
2 answers
236 views

Need help in extracting value counts from a list of dictionaries using python

I am looking to calculate the % of values against keys from a List of dictionaries and their corresponding counts along with values and their corresponding count using Python. Used below code to ...
Sherlock 's user avatar
1 vote
2 answers
56 views

Need help in extracting key list from List of dictionaries and corresponding counts using Python

Hi I am looking to extract list of all keys from a List of dictionaries and their corresponding counts using Python. Used below code but counden't do it can some one help me in this regard The Data ...
Sherlock 's user avatar
2 votes
1 answer
127 views

'>' not supported between instances of 'str' and 'int' pandas function for getting threshold

I have a df import pandas as pd df= pd.DataFrame({'ID': [1,2,3], 'Text':['This num dogs and cats is (111)888-8780 and other', ...
ER510's user avatar
  • 25

15 30 50 per page