I wanted to change the entire row where index is 9 how can i do that

+1 vote

Sep 16, 2019 in Python by anonymous
499 views

1 answer to this question.

0 votes

Import the file as a pandas dataframe and then you this code(Make necessary changes):

import pandas as pd

df = pd.read_csv("<path/to/file>")

df.loc[9]=["asdad","atrptort"]

print(df)
answered Sep 16, 2019 by Rishi

Thanks alot. I have one more problem now i wanted to change the date time format to YYYY-MM-SS HH:MM:SS so can you please suggest some peace of code to satisfy this solution.

Thanks.

Try this:

import datetime

date1 = "3/05/18 12:39"
date, time = date1.split(' ')
date2 = datetime.datetime.strptime(date, '%d/%m/%y').strftime('%Y/%m/%d')
date2 = (date2+' '+time)
print(date2)

Related Questions In Python

0 votes
1 answer

How can I find out the index of an element from row and column in Python?

You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,720 points
2,034 views
0 votes
1 answer

How can I change the data type to string in Python?

You can use str(variablename) This is called conversion ...READ MORE

answered Dec 18, 2018 in Python by Shuvodip
709 views
0 votes
1 answer
–1 vote
2 answers
0 votes
1 answer

I want to download a file from the website by web scraping. Can anyone explain how to do this in jupyter lab (python) with an example?

Hey, Web scraping is a technique to automatically ...READ MORE

answered Apr 7, 2020 in Python by Gitika
• 65,910 points
2,100 views
0 votes
1 answer

How do I get the path and name of the file that is currently executing?

Hello @kartik, Since Python 3 is fairly mainstream, ...READ MORE

answered May 11, 2020 in Python by Niroj
• 82,880 points
2,321 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP