Skip to content

Issue filtering by ip address #46

Open
@rmbittmann

Description

@rmbittmann

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions