Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Unix is the worst operating system; except for all others. -- Berry Kercheval


devel / comp.lang.python / Update a specific element in all a list of N lists

SubjectAuthor
o Update a specific element in all a list of N listshanan lamaazi

1
Update a specific element in all a list of N lists

<mailman.8.1639663274.1567.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20837&group=comp.lang.python#20837

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: hanan.lamaazi@gmail.com (hanan lamaazi)
Newsgroups: comp.lang.python
Subject: Update a specific element in all a list of N lists
Date: Thu, 16 Dec 2021 18:00:57 +0400
Lines: 68
Message-ID: <mailman.8.1639663274.1567.python-list@python.org>
References: <CADFspfotj+9h42yAb4+Yu5Gxw_jYJ7KNSff7UP0UGpabGs-P_Q@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de G5+z/6+FJ+Eyw8hWD7rkEwRff0/WuOnwjxvGz732p0zA==
Return-Path: <hanan.lamaazi@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=I79h4R4r;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.034
X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'error:': 0.05;
'dataframe': 0.09; 'ids': 0.09; 'subject:list': 0.11; 'append':
0.16; 'column': 0.16; 'columns': 0.16; 'dataset': 0.16; 'locate':
0.16; 'slot': 0.16; 'subject:element': 0.16; 'subject:lists':
0.16; 'thankful': 0.16; 'problem': 0.16; 'values': 0.17; 'to:addr
:python-list': 0.20; 'all,': 0.20; 'code': 0.23; 'anyone': 0.25;
'tried': 0.26; 'greatly': 0.28; 'whole': 0.30; "doesn't": 0.32;
'message-id:@mail.gmail.com': 0.32; 'but': 0.32; "i'm": 0.33;
'there': 0.33; 'received:google.com': 0.34; 'trying': 0.35;
'from:addr:gmail.com': 0.35; 'those': 0.36; 'lists': 0.37; 'main':
0.37; 'really': 0.37; 'using': 0.37; 'received:209.85': 0.37;
'received:209': 0.39; 'single': 0.39; 'list': 0.39; 'use': 0.39;
'received:209.85.222': 0.39; 'skip:o 10': 0.61; 'dear': 0.62;
'gives': 0.62; 'here': 0.62; 'skip:o 20': 0.63; 'your': 0.64;
'time,': 0.67; 'right': 0.68; 'repeatedly': 0.69; 'reputation':
0.84; 'subject:specific': 0.84; 'skip:d 30': 0.86
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:from:date:message-id:subject:to;
bh=Y13R/3nfJDtHEFp0QrpVrD7Kq8/VvIyWneD4ZaY4MQo=;
b=I79h4R4rJ50jMX9bmHtUPLvvQlgHrbeOMDb8OjGgT+R5iAHwo4hAKiVJKiymX+50Ns
wDI4Lie7Aea/XrVH7qHHqA8Xlxo14fyyrvFU3XFaWSs9JQ1cx91NR0mRn3BE3V+hRguV
D/mcK+8Dv8IZeEbDTufCAH8MvJaw3jfb6IrfEICxjCjhiqQDlj9TzLm21tjcLk0r9+HZ
laAdhVkr08pAo1RlM4I3cUmUmHKstj/T1crMlsmi+y5oqOUlnPUube/k6ItSKGJXyRMi
/z1VhUxb/t9cZcjTpjecpmElWN5GuelfvZ3OD7U2kXKQQVrkJhFggH8y+zViUhl0aDyU
d2ZQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
bh=Y13R/3nfJDtHEFp0QrpVrD7Kq8/VvIyWneD4ZaY4MQo=;
b=K7eU7sJdxrP6MH12Qf6l3JpMm5VGHaieTMrndhUMhVVowtYWSPj4zaBdIyr+dNX1yw
hGoqxmHiin6iw+2a1iQTjwvORQPX2N4hcRtFRKyCgZr0UEshUqstjz7lJ6ZueG5qTktI
m9hGlxMgzKymt6NvSIG2Ye6JO4hAlYcNr7euEHdB6aJrmRHsxf4xSrEluLboTZRC+b+k
UuYzFCH2EgqJb4cI2uVhPQdVLwksKFo6hEsoVV78x5es4VIBM/nIV2ydaXfMGwVjRA9+
M3C0hC+pPwl40+4lVXBho63TFcVQOZnYG3DdMGZ6Ohn+Xm35Y1e9BxguKhz3qPm0nSGg
uX3g==
X-Gm-Message-State: AOAM532yWib9HJbCSHqVVe0FEGb2IOi31xtwWMnBqgv0wosBfUoLLkaO
lqqonid2jl2L76zZVRkBsK/yC8ZvA6VhuQq5tcECv8V0reU=
X-Google-Smtp-Source: ABdhPJz+PMZPmuymvW20TA4M4JSo0kPABm1R1Un+L6ASZyCt474Nta2dgw2mprg+8Q6vbuanFZroi6lx8ettEhWQJag=
X-Received: by 2002:a67:301:: with SMTP id 1mr5776326vsd.11.1639663267890;
Thu, 16 Dec 2021 06:01:07 -0800 (PST)
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CADFspfotj+9h42yAb4+Yu5Gxw_jYJ7KNSff7UP0UGpabGs-P_Q@mail.gmail.com>
 by: hanan lamaazi - Thu, 16 Dec 2021 14:00 UTC

Dear All,

I really need your assistance,

I have a dataset with 1005000 rows and 25 columns,

The main column that I repeatedly use are Time, ID, and Reputation

First I sliced the data based on the time, and I append the sliced data in
a list called "df_list". So I get 201 lists with 25 columns

The main code is starting for here:

for elem in df_list:

{do something.....}

{Here I'm trying to calculate the outliers}

Out.append(outliers)

Now my problem is that I need to locate those outliers in the df_list and
then update another column with is the "Reputation"

Note that the there is a duplicated IDs but at different time slot

example is ID = 1 is outliers, I need to select all ID = 1 in the list and
update their reputation column

I tried those solutions:
1)

grp = data11.groupby(['ID'])
for i in GlobalNotOutliers.ID:
data11.loc[grp.get_group(i).index, 'Reput'] += 1

for j in GlobalOutliers.ID:
data11.loc[grp.get_group(j).index, 'Reput'] -= 1

It works for a dataframe but not for a list

2)

for elem in df_list:

elem.loc[elem['ID'].isin(Outlier['ID'])]

It doesn't select the right IDs, it gives the whole values in elem

3) Here I set the index using IDs:

for i in Outlier.index:
for elem in df_list:
print(elem.Reput)
if i in elem.index:
# elem.loc[elem[i] , 'Reput'] += 1
m = elem.iloc[i, :]
print(m)

It gives this error:

IndexError: single positional indexer is out-of-bounds

I'm greatly thankful to anyone who can help me,


devel / comp.lang.python / Update a specific element in all a list of N lists

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor