All Questions
24 questions
0
votes
2
answers
419
views
Function for converting columns of a data frame into key value pairs
I have a dataframe (these are just sample columns for reference, the actual number of columns is quite large)
id
A
B
C
D
123
24
98
74
32
456
65
90
61
96
I would like to convert it into a data where id ...
0
votes
2
answers
828
views
Pandas dataframe : Iterate over rows an item in column that contains list
I have a dataframe where an column cells contain lists of multiple values.
I'd like to iterate each item in the list over all rows and check if the item exist in the column 'id', if the case add the ...
0
votes
1
answer
46
views
How do I iterate over a column dataframe made of lists with an index made of other column dataframe?
So I have a dataframe with different columns. I want to use three. One is a list of different sizes, other two are two columns made of just one number. I want to create a new column made of the ...
0
votes
1
answer
67
views
Get specific elements of a list using a list iteration
I'm trying to build the below dataframe
df = pd.DataFrame(columns=['Year','Revenue','Gross Profit','Operating Profit','Net Profit'])
rep_vals =['year','net_sales','gross_income','operating_income','...
0
votes
1
answer
27
views
how to iterate dataframes where name types in list are strings
I have a list which includes dataframe names
abc=list(dictfortoday.keys())
print(abc)
Output:
['portfel0','portfel1','portfel2']
And all items in list is dataframe
I want to iterate them as below
...
0
votes
2
answers
82
views
Remove from a list (or DataFrame) substrings contained the same list
I have a list of lists (let's call it IDlist): what i want to do is removing the elements (lists) of IDlist that are "substrings" of other elements (other lists) of IDlist.
It is not ...
0
votes
3
answers
226
views
Iterating over lists in pandas dataframe to remove everything after certain value (if the value exists) in list
I want to filter my dataframe values based on the occurrence of '1' in my column events. When a 1 occurres, everything after the 1 should be removed.
I want to do this for my whole dataframe, which ...
0
votes
0
answers
89
views
pandas intervals: list length not matching dataframe length
given a column of intervals in a dataframe, I am checking if every single cell is equal to any of the elements contained in 'cat_list'. Every time this condition is true, the list 'inter_group' is ...
0
votes
1
answer
430
views
How to replace elements in Pandas Dataframes with list values based on specific conditions?
I have a CSV file which contains 2 columns, Query and Description. This is the example description of the file:-
| Query | Description |
| -------- ...
0
votes
1
answer
93
views
Combine dataframe within the list to form a single dataframe using pandas in python [duplicate]
Let say I have a list df_list with 3 single column pandas dataframe as below:
>>> df_list
[ A
0 1
1 2
2 3, B
0 4
1 5
2 6, C
0 7
1 8
2 9]
I would like to merge them to become ...
0
votes
1
answer
450
views
Iterate over list of keys and add to Pandas DF if key present in given row/column
I have a fairly large (57k rows) data file I regularly access that contains personnel listings and their skill sets. I'd like to feed a keyword list and output a DF with only rows where those keys ...
1
vote
1
answer
227
views
Converting 3d list into pandas single dataframe on same index
My list l has shape np.array(l).shape (100,15,1) It has 100 dataframes with each df having 15 rows and 1 column. The index are same, just the sorting is different in each df of list.
I want to unzip ...
1
vote
1
answer
1k
views
How to store a df.column in a list without index in a loop?
df.shape (15,4)
I want to store 4th column of df within the loop in a list. What I'm trying is:
l=[]
n=1000 #No. of iterations
for i in range(0,n):
#df expressions and results calcualtion ...
1
vote
1
answer
38
views
Iterate over list (2 dataframes in 1 list)
I am importing 2 data frames at the same time:
import pandas as pd
import numpy as np
import time
import glob
import os
msci_folder = 'C:/Users/Mike/Desktop/docs'
mscifile = glob.glob(msci_folder + &...
0
votes
0
answers
24
views
How to generalise an iteration in a mutliple list
I am a beginner in pyhton pandas. I am looking a way of generalizing an iteration in a multiple list. I have a list 448 elements(multiple list). So i need after 4 elements to group from element 5 to ...