#🔒 grabbing part of the ip octet but python reads it as decimal

11 messages · Page 1 of 1 (latest)

upbeat pier
#

Hello, Im having trouble when fecthing the 2nd and 3rd part of the IP because python thinks its a decimal and takes out my 0 from the last part , so for example I have and IP 10.x.y.1 and the x.y is in the same excel cell and has a valeu of 110.190 . When panda goes to grab it, it returns as 110.19 making the last 0 disappear. anyone know a solution for this ?

´´
equipamento = equipamentos_df.loc[equipamentos_df['GEPE'] == gepe]
xy = equipamento['z_ip_xy'].values[0]
ip = f"10.{xy}.2"
´´´

stable lightBOT
#

@upbeat pier

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

timid swift
#
ip = f"10.{xy:.3}.2"
#

the proper way would be to specify the dytpe of that column as a string when you load the file

upbeat pier
#

thanks, I did the second way and it workd just fine 🙂

#

!closed

stable lightBOT
#
Did you mean:

!close

upbeat pier
#

!close

stable lightBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.