question

Upvotes
Accepted
1 0 0 0

Wieso funktioniert die .at() Funktion bei Pandas nicht?

I have the following code in which I access a CSV file with multiple columns containing numbers and want to change a specific column under certain conditions:


import csv

import pandas


final_activities = pandas.read_csv("VPN2/VPN2_Final_Activities.csv", delimiter=';', names=['Timerels', 'ActivityClass_Ankle', 'ActivityClass_Hip', 'ActivityClass_Thigh', 'ActivityClass_Wrist', 'ActivityClass_Annotation'], skip_blank_lines=True, skipinitialspace=True, engine='python', header=0)


i = 0

while i < len(final_activities):

ankle_activity = final_activities.loc[i][1]

annotation_activity = final_activities.loc[i][5]

if(int(annotation_activity) == 9 and int(ankle_activity) == 2):

final_activities.at[i, 'ActivityClass_Ankle'] = 9

i += 1


In this case, nothing is being modified in the final_activities DataFrame due to the .at statement. It used to work for me before. Please help!

python#productpython apipandas
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi @RandomMonkey ,

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?
If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,
AHS

Hi,

Please be informed that a reply has been verified as correct in answering the question, and marked as such.

Thank you,

AHS

1 Answer

· Write an Answer
Upvote
Accepted
24.7k 54 17 14

Hello @RandomMonkey

Thank you for contacting us. Unfortunately, this Q&A forum is dedicated to Refinitiv/LSEG APIs general usage questions only.

If you need help using the Pandas library, I strongly suggest you post the question on the following forums instead:

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.