agf1997 agf1997 - 28 days ago 10
Python Question

Changing value of an index in pandas dataframes

I have a series of dataframes in a dict.

type(mydict[0])
pandas.core.frame.DataFrame

print(dict[0])

0 1 2
0 0.278735 0.609862 0.085823
1 0.836997 0.739635 0.866059
2 0.691271 0.377185 0.225146

print(dict[1])

0 1 2
3 0.435280 0.700900 0.700946
4 0.796487 0.018688 0.700566
5 0.900749 0.764869 0.253200


How can I change the value of the index of
dict[1]
to such that it looks like this

print(dict[0])

0 1 2
0 0.278735 0.609862 0.085823
1 0.836997 0.739635 0.866059
2 0.691271 0.377185 0.225146

print(dict[1])

0 1 2
0 0.435280 0.700900 0.700946
1 0.796487 0.018688 0.700566
2 0.900749 0.764869 0.253200

Answer

Try:

mydict[1].reset_index(drop=True, inplace=True)
Comments