close

[Solved] ValueError: No axis named node2 for object type

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error ValueError: No axis named node2 for object type <class ‘pandas.core.frame.DataFrame’> in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ValueError: No axis named node2 for object type <class ‘pandas.core.frame.DataFrame’> Error Occurs?

Today I get the following error ValueError: No axis named node2 for object type <class ‘pandas.core.frame.DataFrame’> in python.

How To Solve ValueError: No axis named node2 for object type <class ‘pandas.core.frame.DataFrame’> Error ?

  1. How To Solve ValueError: No axis named node2 for object type Error ?

    To Solve ValueError: No axis named node2 for object type <class 'pandas.core.frame.DataFrame'> Error You need [] in groupby:
    .groupby(['node1','node2'])

  2. ValueError: No axis named node2 for object type >

    To Solve ValueError: No axis named node2 for object type <class 'pandas.core.frame.DataFrame'> Error You need [] in groupby:
    .groupby(['node1','node2'])

Solution 1


You need [] in groupby:

.groupby(['node1','node2'])

mask = ndf.groupby(['node1','node2']).apply(lambda x : (x['date'].dt.year.isin(l1)).any())
print (mask)
node1  node2
1      8         True
       316      False
2      26        True
       35       False
       56        True
3      44       False
dtype: bool

mask2 = ndf.groupby(['node1','node2']).apply(lambda x : (x['date'].dt.year.isin(l2)).any())
print (mask2)
node1  node2
1      8        False
       316       True
2      26       False
       35        True
       56       False
3      44        True
dtype: bool

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read