0

I have a set of values: false.csv
I have index values as:

Time
2019.01.02 06:01:00
2019.01.02 06:09:00
2019.01.02 06:12:00
2019.01.02 06:19:00
2019.01.02 06:21:00
2019.01.02 06:26:00
2019.01.02 06:44:00

I want to set the values to zero for the above index which are in separate file. I tried to load the data but could not get the path to move forward.

here is the way I loaded data:

import pandas as pd
df = pd.read_csv("false.csv")
df1= pd.read_csv("set.csv")

Let me know how I can move forward.

3
  • sorry but i didnt understand the question. Can you add more details to "I want to set the values to zero for the above index which are in separate file." Commented Mar 14, 2019 at 11:01
  • You see the main dataset is the false.csv. I have collected the few indexes and want the values of those indexes in the main file as zero. If they are one then set to zero if there are zero still set to zero. Commented Mar 14, 2019 at 11:02
  • I edited in the dataset because that is what is usually expected around here. Please consider reverting your edit to show it. If you feel it is too long, than produces a shorter one that is a proper MCVE. Commented Mar 14, 2019 at 11:16

1 Answer 1

1

First, when you load the false file make sure your index is by date:

df = pd.read_csv("false.csv",index_col=0)
df1= pd.read_csv("set.csv")

Next, just set what you need to 0:

df.loc[df1['Time']] = 0

loc matches indices, rather than titles.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.