All Questions
49 questions
0
votes
1
answer
95
views
for loop in Pandas to append values based on list condition
I am iterating through a dataframe of 2 columns, ["Tumor Volume (mm3)"] and ["Drug Regimen"]. I have a 2 lists made, one called Treatment with 4 specific drugs, and an empty list ...
-2
votes
1
answer
44
views
How to iterate through a list of tuples and make pairs out of them?
I have a list like this:
point_list = [(54,8),(55,9),(56,10),(57,11)]
and now I want to make them as pairs like:
[(54,8),(55,9)],[(55,9),(56,10)],[(56,10),(57,11)],[(57,11),(54,8)]
and I have a ...
0
votes
1
answer
70
views
How to append multiple dataframes using a filter function
I am using the below code to iterate through many data frames based on a few keywords. There are 20 data frames and about 30 columns. I am not able to append each data frame to create a list of data ...
0
votes
3
answers
94
views
Iteratively pop and append to generate new lists using pandas
I have a list of elements mylist = [1, 2, 3, 4, 5, 6, 7, 8] and would like to iteratively:
copy the list
pop the first element of the copied list
and append it to the end of the copied list
repeat ...
0
votes
2
answers
60
views
Cannot append list with condition
im trying to export two lists to an excel file using pandas, but i cannot append my data using this method.
product_list1 = ["apple", "pear", "oragne", "melon"]
...
0
votes
0
answers
69
views
How can I simplify multiple "append"?
I'm doing nested looping. However, my code is kind of messy because I use a lot of append list. I just simplify my parameters to make them more comfortable to look. Is there any method to simplify the ...
0
votes
0
answers
23
views
why is the list(act_lt) not appending normally as it should [duplicate]
Am new in Python(programming) and pygame and I am trying to make a game and whenever i run the code , the act_lt is throwing away the first saved elements and saving the current speed.
Here is the ...
1
vote
2
answers
37
views
How to add a list of lists to a df at an specific column on Python? Pandas related
Suppose that I have the following df with empty strings in the Volatility expected column:
Index Time Currency Volatility expected Event Actual Forecast ...
0
votes
1
answer
20
views
Python - Code returns dates but when added to list the format changes
I am trying to create a list of dates to add to a Pandas dataframe as a new column using ...
df['Surveys_Last_Week'] = list
I have done this before without issues. However, with the code below I get ...
-1
votes
1
answer
293
views
Python: append not adding to an empty list
Hi sorry if this is an obvious one, looked around online and I can't seem to find what I'm doing wrong.
I am trying to compare the contents of two lists, in two separate csv files (file A and file B). ...
1
vote
1
answer
126
views
Looping over dataframe only returns one column [duplicate]
I have a dataframe formatted like this:
index join file
0 inner join a
1 on xxx a
2 inner join on yyy b
3 left join c
I am running ...
0
votes
1
answer
375
views
Find each keyword in a text file and record with file name
I have downloaded ~100 stored procs as .txt files from SQL Server. From these txt files I am looking to record every iteration of a keyword beginning with "XXX". So every time the word ...
0
votes
2
answers
68
views
Appending elements of a list into a multi-dimensional list
Hi I'm doing some web scraping with NBA Data in python on this page. Some elements of basketball-reference are easy to scrape, but this one is giving me some trouble with my lack of python knowledge.
...
0
votes
1
answer
41
views
Merge multiple list scraped from HTML using Python
I am trying to scrape the list of name from a web and need to list it in the form of Pandas.
import pandas as pd
images = soup.find_all('img')
for elements in images:
x = elements['alt'] # str
y =...
0
votes
1
answer
35
views
Querying a list object from API and returning it into dataframe - issues with format
I have the below script that returns data in a list format per quote of (i). I set up an empty list, and then query with the API function get_kline_data, and pass each output into my klines_list with ...
0
votes
2
answers
25
views
appending to lists in column of dataframe
I have a column in a dataframe containing lists of strings as such:
id colname
1 ['str1', 'str2', 'str3']
2 ['str3', 'str4']
3 ['str3']
4 ['str2', 'str5', 'str6']
..
The strings in ...
0
votes
1
answer
226
views
append list with for loop and get multiple values in each cell in python
I'm trying to run 3 optimization with for loop and store the results in one dataframe.
After each optimization (element of the for loop), I append lists of results and being able to get all the reults ...
0
votes
3
answers
72
views
How to append to list without inserting a list within a list?
I have a dictionary with origin:row_rate as key-value pair. df2 is a pandas dataframe and as I iterate through the dataframe, I wanted to append the row_rate into the values of their corresponding ...
2
votes
1
answer
41
views
Appending list from dataframe with for statement
In school learning Python. Working on a project and I wanted to remove specific rows from one dataframe and turn it into another dataframe. I have a list of 372 animals and if their names show up in ...
0
votes
3
answers
2k
views
How to assign a dictionary to each of another dictionary's values in Python?
I have two dictionaries which are related in content. One is formed from a data set taking the 'shopid' as the key and taking 'userid' as the value. The other dictionary is formed from the same data ...
0
votes
1
answer
48
views
append function not working for DataFrame
I am trying to append the data frame in the different list to different data frame but each time the same data frame is only appending after on time
list1, list2, list3, list4 = [],[],[],[]
def ...
0
votes
1
answer
36
views
Manipulating row data in CSV file and appending it in a new column using Python
I have an csv file consisting of a list of company names.
The goal is to write a code to generate the direct indeed job listing link for each of these companies using the name alone.
The indeed link ...
1
vote
1
answer
166
views
Appending to a list inside a pandas dataframe
I have a pandas dataframe with a column of empty lists. I want to append to this list at a specific location within the dataframe. Below is the code I'm using.
df = pd.DataFrame([[1, 2], [4, 5], [7, ...
1
vote
2
answers
101
views
Adding new rows in the existing columns based on condition
I have a dataframe which has four columns that is range,weather,flag and calculation.I need to take the combinations from the three list for three columns (range,weather and flag) and check if the ...
-1
votes
3
answers
6k
views
Pandas Dataframe Apply - lambda function appending to list
I have a list contained in a column of a pandas dataframe. And I want to append the value in the "price_label" column to the list.
I'm currently using a function i've made to do this, but is it the ...
0
votes
3
answers
174
views
Slicing/Splitting certain characters from the csv file name
I am using pandas library to read 30 csv files in the folder. The following are the name of the files located in the folder "deg_pvsyst_runs" in the path
S:/Home/deg_pvsyst_runs/:
Files are named as:...
13
votes
5
answers
56k
views
Append values from dataframe column to list
I have a dataframe with several columns, and I want to append to an empty list the values of one column, so that the desired output would be the following:
empty_list = [value_1,value_2,value_3...]
...
0
votes
2
answers
885
views
Python: How can I check if an item in a list contains a string within an elif statement where two conditions must be met?
I'm making a scraper in python that executes a search, then opens each link in the search and makes a list of everything within a strong tag.
Then it append the list to a Dataset. Not all of the ...
-5
votes
1
answer
80
views
For loop with append list
"year" data not append s list.
for loop with files station number based later based items append "s" list. ?
s = []
while t < t+1:
for p in range(0,t):
k = df_st3[p] == ...
1
vote
0
answers
53
views
Python list append: multiple appends per iteration [duplicate]
I have a dataframe that contains many rows row (order of 60000) with the three fields:
shift: a string of 96 characters indicating the location or 'r' (no location; e.g. '...
0
votes
4
answers
550
views
How to replace elements within a pandas dataframe column according to an ordered list?
Lets say I have this pandas dataframe:
index a b
1 'pika' 'dog'
2 'halo' 'cat'
3 'polo' 'dog'
4 'boat' 'man'
5 'moan' 'tan'
6 'nope' 'dog'
and I have a list ...
2
votes
2
answers
287
views
Appending columns to a new dataframe
I have a dataframe that looks like this.
df =
0 1 2 3 4
0 0.5 0.4 0.3 0.2 0.1
1 0.5 0.4 0.3 0.2 0.1
2 0.5 0.4 0.3 0.2 0.1
3 0.5 0.4 0.3 0.2 0.1
And a list of lists that looks ...
0
votes
3
answers
670
views
Iterating through pandas dataframe and appending to a list
I have a pandas dataframe df
Date SKU Balance
0 1/1/2017 X1 8
1 2/1/2017 X2 45
2 3/1/2017 X1 47
3 4/1/2017 X2 16
4 5/1/2017 ...
2
votes
6
answers
110
views
Append a String to a String in a List
I am reading an excel table:
import pandas as pd
df = pd.read_excel('file.xlsx', usecols = 'A,B,C')
print(df)
Now I want to create a list with every row in the table as string.
In addition I want ...
1
vote
2
answers
72
views
How to append from multiple dictionaries in a List to another list with specific parts of the "inner" dictionary?
I've got dictionaries in a list:
fit_statstest = [{'activities-heart': [{'dateTime': '2018-02-01',
'value': {'customHeartRateZones': [],
'heartRateZones': [{'caloriesOut': 2119.9464,
'max': 96,
...
0
votes
0
answers
124
views
what is the most efficient way to search for a string in a pandas column?
I wrote this code it takes an input string gets similar words to it
and creates a different combinations of these words, searches for each combination in a pandas column and returns the index of the ...
4
votes
2
answers
7k
views
List append in pandas cell
I have a dataframe which contains list item in a column.
Example:
df:
column1, column2, column3
1 'c' ['d']
2 'x' []
3 'foo' ['car']
so I want to append ...
0
votes
2
answers
41
views
python appends to all dictionaries
I am using dictoinaries inside of dictionaries. Looping through a pandas dataframe, the value of the action row always matches one of the keys in the dictionary, and based on that some other values ...
5
votes
3
answers
6k
views
How to append item to list of different column in Pandas
I have a dataframe that looks like this:
dic = {'A':['PINCO','PALLO','CAPPO','ALLOP'],
'B':['KILO','KULO','FIGA','GAGO'],
'C':[['CAL','GOL','TOA','PIA','STO'],
['LOL','DAL','...
2
votes
1
answer
1k
views
How does one populate a row in pandas python
I have initialised a dataframe in python to simulate a matrix
llist = ["this", "is", "a","sentence"]
df = pd.DataFrame(columns = llist, index = llist)
Now I want to populate a row as follows
...
1
vote
1
answer
1k
views
Adding row to dataframe in pandas
Suppose I am trying add rows to a dataframe with 40 columns. Ordinarily it would be something like this:
df = pandas.DataFrame(columns = 'row1', 'row2', ... ,'row40'))
df.loc[0] = [value1, value2, .....
2
votes
1
answer
116
views
Append new column to df from list using python
I have list lst = ['vk.com', 'facebook.com', 'avito.ru', 'twitter.com']
and I want to add it to this df:
date id request
2016-06-17 09:26:18 [email protected] GET HTTP/1.1
2016-06-17 09:38:...
0
votes
1
answer
65
views
Running through appended data frame to locate where the first positive number is in python
I have a appended series using pandas. I will call it S. Each S[i], for some i, has 50 data points. I will call these j.
I want to go through each i, and for instance for j=1, find where the first ...
0
votes
1
answer
97
views
Python append value to list of unique objects
Please forgive any naiveté in this question. I have been actively trying to form a rudimentary understanding of programming over the last few months. There are many gaps, so I may not know what I don'...
0
votes
2
answers
763
views
Selecting a data value from pandas dataframe based on row and column to append to list
I have a PandasData Frame that is 26 columns and 100 rows. I want to extract a particular value from column 25 (which is called Unnamed: 24) row 50 and throw it into a list. Is there any way to do ...
2
votes
3
answers
149
views
Appending individual items to lists in pandas Series
I am creating a Multiindexed pandas Series and each item is a list. First, an empty list, then I append each of these lists individually. However, when I tried to do that in a naive manner, I've faced ...
0
votes
1
answer
513
views
Splitting list according to criteria (gender)
I'm a beginner in python, just learning how to write functions. I've got a list of weights and gender, and am trying to split it to create two new lists according to the gender criteria. Using for ...
1
vote
1
answer
1k
views
Print columns of Pandas dataframe to separate files + dataframe with datetime (min/sec)
I am trying to print a Pandas dataframe's columns to separate *.csv files in Python 2.7.
Using this code, I get a dataframe with 4 columns and an index of dates:
import pandas as pd
import numpy as ...
2
votes
1
answer
1k
views
Python Pandas Append List of Dataframes [closed]
This is a sort of simple question but I don't think it has been asked before.
If I have a list of dataframes (they need to be in this format because of multiprocessing),
df_list=[df1,df2,...,dfn]
...