Entering Pandas Data

Asked 2 years ago, Updated 2 years ago, 46 views

Hello, I have a question for Panda's.

I set the time every 10 minutes to organize the data frame In order to extract a specific time zone, we processed the data and configured it using df.set_index. I want to put the data in the part marked NaN, but I can't put it in How can I put the data value in the NaN part?

I'd like to put data on this picture like the original image

#Original data configuration code
df=pd.DataFrame(index=range(0,145))[:145]

time = pd.date_range('2020-11-15','2020-11-16',freq='10min')

df['time']=time

np.random.seed(seed=0)

alphabet=list('ABCDEF')   

df["Country of origin"]=np.random.choice (alphabet, size=145)
df["Destination"]=np.random.choice (alphabet, size=145)

df['' ]=' '

df['A']=0

df['B']=0

df['C']=0

df['D']=0

df['E']=0

df['F']=0
df=pd.DataFrame (index=range (0,145), columns=['time', 'origin', 'destination', 'A', 'B', 'C', 'D', 'E', 'F')

time = pd.date_range('2020-11-15','2020-11-16',freq='10min')

df['time']=time

df['time'] = pd.to_datetime(df['time'])

df.set_index("time",inplace=True)

time2 = df.between_time('08:00:00','23:50:00') #Set a specific time

print(time2)

np.random.seed(seed=0)

alphabet=list('ABCDEF')   

#I want to put this code as a data value
df["Country of origin"]=np.random.choice (alphabet, size=145)
df["Destination"]=np.random.choice (alphabet, size=145)
df['' ]=' '

df['A']=0

df['B']=0

df['C']=0

df['D']=0

df['E']=0

df['F']=0

If there is anyone who knows, please let me know!!!!

pandas dataframe

2022-09-20 19:31

1 Answers

time2 = df.between_time('08:00:00','23:50:00') #set specific time

print(time2)

It's a problem that can be solved quickly if you just try to understand each line of code.

Just move this code last.


2022-09-20 19:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.