Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue filtering by ip address #46

Open
rmbittmann opened this issue Jan 26, 2021 · 0 comments
Open

Issue filtering by ip address #46

rmbittmann opened this issue Jan 26, 2021 · 0 comments

Comments

@rmbittmann
Copy link

Hi,

I might have missed something as I am not that experienced.
When I use cyberpandas to convert to IP address, I cannot filter the data frame based on the IP. Here is an example.

import cyberpandas as cpd
import ipaddress as ip
import numpy as np
import pandas as pd

df = pd.DataFrame(np.array(([ip.IPv4Address('1.1.1.1'), 1], [ip.IPv4Address('2.2.2.2'), 2], [ip.IPv4Address('3.3.3.3'), 3])),
columns=['ip', 'payload'])
df

df['ip'][0] == ip.IPv4Address('1.1.1.1')

df[df['ip'] == ip.IPv4Address('1.1.1.1')]

Works well.

However
df2 = pd.DataFrame(np.array((['1.1.1.1', 1], ['2.2.2.2', 2], ['3.3.3.3', 3])),
columns=['ip', 'payload'])
df2['ip'] = cpd.to_ipaddress(df2['ip'])
df2

df2['ip'][0] == ip.IPv4Address('1.1.1.1')

df2[df2['ip'] == ip.IPv4Address('1.1.1.1')]

In the last command it does not find the correct row as expected as in the previous example, and returns an empty data frame.

What did I miss? What should be done for it to work?

I am using python 3.9.1. with the latest updated packages.

Thanks,
Rani

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant