Questions tagged [iteritems]
27 questions
0
votes
1 answer
Any ideas on Iterating over dataframe and applying regex?
This may be a rudimentary problem but I am new to pandas.
I have a csv dataframe and I want to iterate over each row to extract all the string information in a specific column through regex. . (The reason why I am using regex is because eventually I…

Won Chul Chung
- 77
- 5
0
votes
1 answer
why loop saves only results from last file in pandas
I am using a loop to open consecutive files and then a second loop to calculate the average of y at specific row nrs (x). Why is the second loop showing the average only of the last file? I would like to append the average from each file into one…

Martina Lazzarin
- 179
- 1
- 8
0
votes
1 answer
Keep first occurrence in duplicated values in dictionary
Having duplicated values in dictionary such as the following:
dict_numbers={'one':['one', 'first','uno', 'une'],
'zero':['zero','nothing','cero'],
'first':['one', 'first','uno', 'une'],
…

John Barton
- 1,581
- 4
- 25
- 51
0
votes
1 answer
Pandas dataframe - How to sort (alphabetically) column values with value_counts
I am trying to sort dataframe column values in conjunction with value_count -
Below is a code snippet of my algorithm:
with open (f_out_txt_2, 'w', encoding='utf-8') as f_txt_out_2:
f_txt_out_2.write(f"SORTED First Names w/SORTED value…

user1995818
- 37
- 4
0
votes
1 answer
When one column cell has a value zero, make the value in another column zero and cells below it zero
I'm reading temperature data from a sensor that is cycling on and off in a dataframe df. Each time the sensor turns on, it takes roughly 5 rows of data to thermally equilibrate. I want to ignore the decreased temp values from the warm up time of…

octothor
- 1
- 1
0
votes
0 answers
How does iteritems() work in a loop within dataframe
I am stuck in the understanding of .iteritems(). I checked documents and code examples but that does not explain this specific case.
returns
from statsmodels.tsa.stattools import adfuller
pd.Series([adfuller(values)[1] < 0.05 for columns, values…

Juh
- 9
- 2
0
votes
2 answers
How to get a key among the several values?
I would like to find the key from one value.
But, a key has several values.
I can't find the key by using the typical way to find the key from the value.
I already tried dict.items() and dict.iterms() instead of dict.iteritems()
But doesn't…

Dong-gyun Kim
- 411
- 5
- 23
0
votes
3 answers
Print dict iteration elements as it is read(declared)
I am reading a dictionary in python2.6 as below
I know Python3.6 will read the dictionary in the same order it is declared, but i need to achieve this in Python2.6 (OrderedDict is also not available in Python2.6)
numbermap = {'one': 1, 'two': 2,…

Venkat J
- 305
- 1
- 4
- 12
0
votes
0 answers
python grouper object could not print anything after using itemgetter
I was running the example at
Detecting consecutive integers in a list
from itertools import groupby
from operator import itemgetter
data = [ 1, 4,5,6, 10, 15,16,17,18, 22, 25,26,27,28]
for k, g in groupby(enumerate(data), lambda ix: ix[0] -…

daiyue
- 7,196
- 25
- 82
- 149
0
votes
1 answer
itertools system error for large files
I am trying to get the even lines from my very big file(~300GB),and I am able to do it for a file with almost the same size that I am getting the error is. The code is :
import itertools
import sys, os
with open('FILE.fasta') as f:
fd =…

bapors
- 887
- 9
- 26
0
votes
1 answer
Counter and for loops
I am writing a piece of code that iterates through each record and prints a statistic called intervals.
for record in records:
from collections import Counter
count = Counter(intervals)
for interval, frequency in count.iteritems():
…

nikki_c
- 117
- 1
- 3
- 7
-1
votes
1 answer
Python make list of items according to a dictionary of key value pairs, but values have to be regex patterns
I am trying to make a wrapper function for the existing itertags one here: https://github.com/streamlink/streamlink/blob/master/src/streamlink/plugin/api/utils.py#L16
Currently i have this:
def itertags_wrapper(html, tag, attrs=None, ret=False):
…

Twilight0
- 41
- 7