Why am I not getting some equivalency between calls? /u/MiracleNamedHope Python Education

Why am I not getting some equivalency between calls? /u/MiracleNamedHope Python Education

I’m trying to pull the same range from the same column two seperate ways (once through iloc on the number, and once through loc on the object name), and I’m thinking that the results should be identical – because its the same range from the same column. But its not printing out the same.

The raw data source (Palmer Penguins) is linked inside the code chunk below, so you can copy/paste and run the code on your end to check the column names, row values, etc – or – you can just review the results that I paste in below.

I’m trying to print the rows for penguins 8, 9, and 10 (note you’re seeing index place numbers in the output, not row numbers or values). And if I use the loc method for the column name, it gets me the three rows that I am looking for. But if I use the iloc method on the column number – then it only gets me the rows for penguins 8 and 9 – but not row 10 – it’s like it just ignores this part iof the request, which seems unambiguous.

My question is then: what am I missing, and why am I not getting row 10 if I use this latter iloc method on the column number?

I’ve tried two seperate IDEs and it prints out the same. Here is the code and the output below:

”’

import pandas as pd

penguins = pd.read_csv(‘https://gist.githubusercontent.com/slopp/ce3b90b9168f2f921784de84fa445651/raw/4ecf3041f0ed4913e7c230758733948bc561f434/penguins.csv’)

print(penguins.loc[7:9, [“bill_length_mm”]])

print(penguins.iloc[7:9, [3]])

”’
Output: %runfile C:/Users/rodkr/.spyder-py3/temp.py –wdir

bill_length_mm

7 39.2

8 34.1

9 42.0

bill_length_mm

7 39.2

8 34.1

THANKS!!

submitted by /u/MiracleNamedHope
[link] [comments]

​r/learnpython I’m trying to pull the same range from the same column two seperate ways (once through iloc on the number, and once through loc on the object name), and I’m thinking that the results should be identical – because its the same range from the same column. But its not printing out the same. The raw data source (Palmer Penguins) is linked inside the code chunk below, so you can copy/paste and run the code on your end to check the column names, row values, etc – or – you can just review the results that I paste in below. I’m trying to print the rows for penguins 8, 9, and 10 (note you’re seeing index place numbers in the output, not row numbers or values). And if I use the loc method for the column name, it gets me the three rows that I am looking for. But if I use the iloc method on the column number – then it only gets me the rows for penguins 8 and 9 – but not row 10 – it’s like it just ignores this part iof the request, which seems unambiguous. My question is then: what am I missing, and why am I not getting row 10 if I use this latter iloc method on the column number? I’ve tried two seperate IDEs and it prints out the same. Here is the code and the output below: ”’ import pandas as pd penguins = pd.read_csv(‘https://gist.githubusercontent.com/slopp/ce3b90b9168f2f921784de84fa445651/raw/4ecf3041f0ed4913e7c230758733948bc561f434/penguins.csv’) print(penguins.loc[7:9, [“bill_length_mm”]]) print(penguins.iloc[7:9, [3]]) ”’ Output: %runfile C:/Users/rodkr/.spyder-py3/temp.py –wdir bill_length_mm 7 39.2 8 34.1 9 42.0 bill_length_mm 7 39.2 8 34.1 THANKS!! submitted by /u/MiracleNamedHope [link] [comments] 

I’m trying to pull the same range from the same column two seperate ways (once through iloc on the number, and once through loc on the object name), and I’m thinking that the results should be identical – because its the same range from the same column. But its not printing out the same.

The raw data source (Palmer Penguins) is linked inside the code chunk below, so you can copy/paste and run the code on your end to check the column names, row values, etc – or – you can just review the results that I paste in below.

I’m trying to print the rows for penguins 8, 9, and 10 (note you’re seeing index place numbers in the output, not row numbers or values). And if I use the loc method for the column name, it gets me the three rows that I am looking for. But if I use the iloc method on the column number – then it only gets me the rows for penguins 8 and 9 – but not row 10 – it’s like it just ignores this part iof the request, which seems unambiguous.

My question is then: what am I missing, and why am I not getting row 10 if I use this latter iloc method on the column number?

I’ve tried two seperate IDEs and it prints out the same. Here is the code and the output below:

”’

import pandas as pd

penguins = pd.read_csv(‘https://gist.githubusercontent.com/slopp/ce3b90b9168f2f921784de84fa445651/raw/4ecf3041f0ed4913e7c230758733948bc561f434/penguins.csv’)

print(penguins.loc[7:9, [“bill_length_mm”]])

print(penguins.iloc[7:9, [3]])

”’
Output: %runfile C:/Users/rodkr/.spyder-py3/temp.py –wdir

bill_length_mm

7 39.2

8 34.1

9 42.0

bill_length_mm

7 39.2

8 34.1

THANKS!!

submitted by /u/MiracleNamedHope
[link] [comments]  I’m trying to pull the same range from the same column two seperate ways (once through iloc on the number, and once through loc on the object name), and I’m thinking that the results should be identical – because its the same range from the same column. But its not printing out the same. The raw data source (Palmer Penguins) is linked inside the code chunk below, so you can copy/paste and run the code on your end to check the column names, row values, etc – or – you can just review the results that I paste in below. I’m trying to print the rows for penguins 8, 9, and 10 (note you’re seeing index place numbers in the output, not row numbers or values). And if I use the loc method for the column name, it gets me the three rows that I am looking for. But if I use the iloc method on the column number – then it only gets me the rows for penguins 8 and 9 – but not row 10 – it’s like it just ignores this part iof the request, which seems unambiguous. My question is then: what am I missing, and why am I not getting row 10 if I use this latter iloc method on the column number? I’ve tried two seperate IDEs and it prints out the same. Here is the code and the output below: ”’ import pandas as pd penguins = pd.read_csv(‘https://gist.githubusercontent.com/slopp/ce3b90b9168f2f921784de84fa445651/raw/4ecf3041f0ed4913e7c230758733948bc561f434/penguins.csv’) print(penguins.loc[7:9, [“bill_length_mm”]]) print(penguins.iloc[7:9, [3]]) ”’ Output: %runfile C:/Users/rodkr/.spyder-py3/temp.py –wdir bill_length_mm 7 39.2 8 34.1 9 42.0 bill_length_mm 7 39.2 8 34.1 THANKS!! submitted by /u/MiracleNamedHope [link] [comments]

Read more

Variables/Functions /u/Flat-Watercress-529 Python Education

Variables/Functions /u/Flat-Watercress-529 Python Education

I’ve been learning python in school and I’ve also done Reeborgs World(not sure if that’s the standard or what) but in RW I understood functions super easily, possibly since I only had limited options for making functions. But now that I’m actually using python, I can’t understand functions or variables for the life of me? Anybody able to give me a hand?

submitted by /u/Flat-Watercress-529
[link] [comments]

​r/learnpython I’ve been learning python in school and I’ve also done Reeborgs World(not sure if that’s the standard or what) but in RW I understood functions super easily, possibly since I only had limited options for making functions. But now that I’m actually using python, I can’t understand functions or variables for the life of me? Anybody able to give me a hand? submitted by /u/Flat-Watercress-529 [link] [comments] 

I’ve been learning python in school and I’ve also done Reeborgs World(not sure if that’s the standard or what) but in RW I understood functions super easily, possibly since I only had limited options for making functions. But now that I’m actually using python, I can’t understand functions or variables for the life of me? Anybody able to give me a hand?

submitted by /u/Flat-Watercress-529
[link] [comments]  I’ve been learning python in school and I’ve also done Reeborgs World(not sure if that’s the standard or what) but in RW I understood functions super easily, possibly since I only had limited options for making functions. But now that I’m actually using python, I can’t understand functions or variables for the life of me? Anybody able to give me a hand? submitted by /u/Flat-Watercress-529 [link] [comments]

Read more

What is the best image recognition model out there for cctv ? Where should I start? /u/sramzz Python Education

What is the best image recognition model out there for cctv ? Where should I start? /u/sramzz Python Education

What is the best image recognition model out there for cctv ? I want to recognise when people ask for the bill in a restaurant

submitted by /u/sramzz
[link] [comments]

​r/learnpython What is the best image recognition model out there for cctv ? I want to recognise when people ask for the bill in a restaurant submitted by /u/sramzz [link] [comments] 

What is the best image recognition model out there for cctv ? I want to recognise when people ask for the bill in a restaurant

submitted by /u/sramzz
[link] [comments]  What is the best image recognition model out there for cctv ? I want to recognise when people ask for the bill in a restaurant submitted by /u/sramzz [link] [comments]

Read more

Housing application script /u/random_bruce Python Education

Housing application script /u/random_bruce Python Education

Long story short I am wanting to apply for married student housing at usu. Last time I applied in the first minute there were 60 applications and I applied in the second minute. Rent is half of what I am paying now for a better place. Can I get some help making a script to apply for me. Thank you in advance

submitted by /u/random_bruce
[link] [comments]

​r/learnpython Long story short I am wanting to apply for married student housing at usu. Last time I applied in the first minute there were 60 applications and I applied in the second minute. Rent is half of what I am paying now for a better place. Can I get some help making a script to apply for me. Thank you in advance submitted by /u/random_bruce [link] [comments] 

Long story short I am wanting to apply for married student housing at usu. Last time I applied in the first minute there were 60 applications and I applied in the second minute. Rent is half of what I am paying now for a better place. Can I get some help making a script to apply for me. Thank you in advance

submitted by /u/random_bruce
[link] [comments]  Long story short I am wanting to apply for married student housing at usu. Last time I applied in the first minute there were 60 applications and I applied in the second minute. Rent is half of what I am paying now for a better place. Can I get some help making a script to apply for me. Thank you in advance submitted by /u/random_bruce [link] [comments]

Read more

New in Python 3.13 /u/sohang-3112 Python Education

New in Python 3.13 /u/sohang-3112 Python Education

Obviously this is a quite subjective list of what jumped out to me, you can check out the full list in official docs.

import copy from argparse import ArgumentParser from dataclasses import dataclass

  • __static_attributes__ lists attributes from all methods, new __name__ in @property:

“` @dataclass class Test: def foo(self): self.x = 0

def bar(self): self.message = 'hello world' @property def is_ok(self): return self.q 

Get list of attributes set in any method

print(Test.static_attributes) # Outputs: ‘x’, ‘message’

new __name__ attribute in @property fields, can be useful in external functions

def printproperty_name(prop): print(prop.name_)

print_property_name(Test.is_ok) # Outputs: is_ok “`

  • copy.replace() can be used instead of dataclasses.replace(), custom classes can implement __replace__() so it works with them too:

“` @dataclass class Point: x: int y: int z: int

copy with fields replaced

print(copy.replace(Point(x=0,y=1,z=10), y=-1, z=0)) “`

  • argparse now supports deprecating CLI options:

parser = ArgumentParser() parser.add_argument('--baz', deprecated=True, help="Deprecated option example") args = parser.parse_args()

configparser now supports unnamed sections for top-level key-value pairs:

from configparser import ConfigParser config = ConfigParser(allow_unnamed_section=True) config.read_string(""" key1 = value1 key2 = value2 """) print(config["DEFAULT"]["key1"]) # Outputs: value1

HONORARY (Brief mentions)

  • Improved REPL (multiline editing, colorized tracebacks) in native python REPL, previously had to use ipython etc. for this
  • doctest output is now colorized by default
  • Default type hints supported (although IMO syntax for it is ugly)
  • (Experimental) Disable GIL for true multithreading (but it slows down single-threaded performance)
  • Official support for Android and iOS
  • Common leading whitespace in docstrings is stripped automatically

EXPERIMENTAL / PLATFORM-SPECIFIC

  • New Linux-only API for time notification file descriptors in os.
  • PyTime API for system clock access in the C API.

submitted by /u/sohang-3112
[link] [comments]

​r/learnpython Obviously this is a quite subjective list of what jumped out to me, you can check out the full list in official docs. import copy from argparse import ArgumentParser from dataclasses import dataclass __static_attributes__ lists attributes from all methods, new __name__ in @property: “` @dataclass class Test: def foo(self): self.x = 0 def bar(self): self.message = ‘hello world’ @property def is_ok(self): return self.q Get list of attributes set in any method print(Test.static_attributes) # Outputs: ‘x’, ‘message’ new __name__ attribute in @property fields, can be useful in external functions def printproperty_name(prop): print(prop.name_) print_property_name(Test.is_ok) # Outputs: is_ok “` copy.replace() can be used instead of dataclasses.replace(), custom classes can implement __replace__() so it works with them too: “` @dataclass class Point: x: int y: int z: int copy with fields replaced print(copy.replace(Point(x=0,y=1,z=10), y=-1, z=0)) “` argparse now supports deprecating CLI options: parser = ArgumentParser() parser.add_argument(‘–baz’, deprecated=True, help=”Deprecated option example”) args = parser.parse_args() configparser now supports unnamed sections for top-level key-value pairs: from configparser import ConfigParser config = ConfigParser(allow_unnamed_section=True) config.read_string(“”” key1 = value1 key2 = value2 “””) print(config[“DEFAULT”][“key1”]) # Outputs: value1 HONORARY (Brief mentions) Improved REPL (multiline editing, colorized tracebacks) in native python REPL, previously had to use ipython etc. for this doctest output is now colorized by default Default type hints supported (although IMO syntax for it is ugly) (Experimental) Disable GIL for true multithreading (but it slows down single-threaded performance) Official support for Android and iOS Common leading whitespace in docstrings is stripped automatically EXPERIMENTAL / PLATFORM-SPECIFIC New Linux-only API for time notification file descriptors in os. PyTime API for system clock access in the C API. submitted by /u/sohang-3112 [link] [comments] 

Obviously this is a quite subjective list of what jumped out to me, you can check out the full list in official docs.

import copy from argparse import ArgumentParser from dataclasses import dataclass

  • __static_attributes__ lists attributes from all methods, new __name__ in @property:

“` @dataclass class Test: def foo(self): self.x = 0

def bar(self): self.message = 'hello world' @property def is_ok(self): return self.q 

Get list of attributes set in any method

print(Test.static_attributes) # Outputs: ‘x’, ‘message’

new __name__ attribute in @property fields, can be useful in external functions

def printproperty_name(prop): print(prop.name_)

print_property_name(Test.is_ok) # Outputs: is_ok “`

  • copy.replace() can be used instead of dataclasses.replace(), custom classes can implement __replace__() so it works with them too:

“` @dataclass class Point: x: int y: int z: int

copy with fields replaced

print(copy.replace(Point(x=0,y=1,z=10), y=-1, z=0)) “`

  • argparse now supports deprecating CLI options:

parser = ArgumentParser() parser.add_argument('--baz', deprecated=True, help="Deprecated option example") args = parser.parse_args()

configparser now supports unnamed sections for top-level key-value pairs:

from configparser import ConfigParser config = ConfigParser(allow_unnamed_section=True) config.read_string(""" key1 = value1 key2 = value2 """) print(config["DEFAULT"]["key1"]) # Outputs: value1

HONORARY (Brief mentions)

  • Improved REPL (multiline editing, colorized tracebacks) in native python REPL, previously had to use ipython etc. for this
  • doctest output is now colorized by default
  • Default type hints supported (although IMO syntax for it is ugly)
  • (Experimental) Disable GIL for true multithreading (but it slows down single-threaded performance)
  • Official support for Android and iOS
  • Common leading whitespace in docstrings is stripped automatically

EXPERIMENTAL / PLATFORM-SPECIFIC

  • New Linux-only API for time notification file descriptors in os.
  • PyTime API for system clock access in the C API.

submitted by /u/sohang-3112
[link] [comments]  Obviously this is a quite subjective list of what jumped out to me, you can check out the full list in official docs. import copy from argparse import ArgumentParser from dataclasses import dataclass __static_attributes__ lists attributes from all methods, new __name__ in @property: “` @dataclass class Test: def foo(self): self.x = 0 def bar(self): self.message = ‘hello world’ @property def is_ok(self): return self.q Get list of attributes set in any method print(Test.static_attributes) # Outputs: ‘x’, ‘message’ new __name__ attribute in @property fields, can be useful in external functions def printproperty_name(prop): print(prop.name_) print_property_name(Test.is_ok) # Outputs: is_ok “` copy.replace() can be used instead of dataclasses.replace(), custom classes can implement __replace__() so it works with them too: “` @dataclass class Point: x: int y: int z: int copy with fields replaced print(copy.replace(Point(x=0,y=1,z=10), y=-1, z=0)) “` argparse now supports deprecating CLI options: parser = ArgumentParser() parser.add_argument(‘–baz’, deprecated=True, help=”Deprecated option example”) args = parser.parse_args() configparser now supports unnamed sections for top-level key-value pairs: from configparser import ConfigParser config = ConfigParser(allow_unnamed_section=True) config.read_string(“”” key1 = value1 key2 = value2 “””) print(config[“DEFAULT”][“key1”]) # Outputs: value1 HONORARY (Brief mentions) Improved REPL (multiline editing, colorized tracebacks) in native python REPL, previously had to use ipython etc. for this doctest output is now colorized by default Default type hints supported (although IMO syntax for it is ugly) (Experimental) Disable GIL for true multithreading (but it slows down single-threaded performance) Official support for Android and iOS Common leading whitespace in docstrings is stripped automatically EXPERIMENTAL / PLATFORM-SPECIFIC New Linux-only API for time notification file descriptors in os. PyTime API for system clock access in the C API. submitted by /u/sohang-3112 [link] [comments]

Read more

Angela Yu’s course is $18.99 – is that the 100 day course? Do we have any alternates to this course? /u/KnownKnowledge8430 Python Education

Angela Yu’s course is $18.99 – is that the 100 day course? Do we have any alternates to this course? /u/KnownKnowledge8430 Python Education

I am a newbie to programming altogether, except for print hello world, i dont have any prior experience

submitted by /u/KnownKnowledge8430
[link] [comments]

​r/learnpython I am a newbie to programming altogether, except for print hello world, i dont have any prior experience submitted by /u/KnownKnowledge8430 [link] [comments] 

I am a newbie to programming altogether, except for print hello world, i dont have any prior experience

submitted by /u/KnownKnowledge8430
[link] [comments]  I am a newbie to programming altogether, except for print hello world, i dont have any prior experience submitted by /u/KnownKnowledge8430 [link] [comments]

Read more

when using phidata, why my agent can’t read the data in the knowledgebase? /u/FunDatabase7098 Python Education

when using phidata, why my agent can’t read the data in the knowledgebase? /u/FunDatabase7098 Python Education

if __name__ == ‘__main__’:

pdf_knowledge_base = PDFKnowledgeBase(

path=”1.pdf”,

vector_db=ChromaDb(

collection=”pdf_knowledge_base”,

embedder=OllamaEmbedder()

),

reader=PDFReader(chunk=False),

)

pdf_knowledge_base.load()

agent = Agent(

knowledge=pdf_knowledge_base,

model=Ollama(id=”qwen2.5:1.5b”)

)

agent.print_response(“pls parse the data in the knowledge base and give me the json output”)

above is the code i write. what should i change to fix this problem.

submitted by /u/FunDatabase7098
[link] [comments]

​r/learnpython if __name__ == ‘__main__’: pdf_knowledge_base = PDFKnowledgeBase( path=”1.pdf”, vector_db=ChromaDb( collection=”pdf_knowledge_base”, embedder=OllamaEmbedder() ), reader=PDFReader(chunk=False), ) pdf_knowledge_base.load() agent = Agent( knowledge=pdf_knowledge_base, model=Ollama(id=”qwen2.5:1.5b”) ) agent.print_response(“pls parse the data in the knowledge base and give me the json output”) above is the code i write. what should i change to fix this problem. submitted by /u/FunDatabase7098 [link] [comments] 

if __name__ == ‘__main__’:

pdf_knowledge_base = PDFKnowledgeBase(

path=”1.pdf”,

vector_db=ChromaDb(

collection=”pdf_knowledge_base”,

embedder=OllamaEmbedder()

),

reader=PDFReader(chunk=False),

)

pdf_knowledge_base.load()

agent = Agent(

knowledge=pdf_knowledge_base,

model=Ollama(id=”qwen2.5:1.5b”)

)

agent.print_response(“pls parse the data in the knowledge base and give me the json output”)

above is the code i write. what should i change to fix this problem.

submitted by /u/FunDatabase7098
[link] [comments]  if __name__ == ‘__main__’: pdf_knowledge_base = PDFKnowledgeBase( path=”1.pdf”, vector_db=ChromaDb( collection=”pdf_knowledge_base”, embedder=OllamaEmbedder() ), reader=PDFReader(chunk=False), ) pdf_knowledge_base.load() agent = Agent( knowledge=pdf_knowledge_base, model=Ollama(id=”qwen2.5:1.5b”) ) agent.print_response(“pls parse the data in the knowledge base and give me the json output”) above is the code i write. what should i change to fix this problem. submitted by /u/FunDatabase7098 [link] [comments]

Read more

Python Subprocess Module /u/bmille49 Python Education

Python Subprocess Module /u/bmille49 Python Education

Hey y’all! New to Python and have existing scripts (9) that run separately, are independent of one another, and 3 of them send emails. The 3 emails can be consumed independently (i.e., vision system utilization, concentrate control system utilization, and inspection utilization) or collectively (e.g., leading indicators). I feel that the collective output would benefit the end customer (supervisors) better than 3 emails and also limit the which one is more important question.

Now to my inquiry, each of the three sends an output of last day use by line by shift, MTD by line by shift and YTD by line by shift. This is done by collecting data, appending to an Excel file, analyzing the data set, and exporting the new summaries (daily, MTD and YTD). Would Python Subprocess Module be a good tool to use for these three scripts, collect their output and then merge the three outputs into one email? Would this open me up to any security issues? Pros and cons?

submitted by /u/bmille49
[link] [comments]

​r/learnpython Hey y’all! New to Python and have existing scripts (9) that run separately, are independent of one another, and 3 of them send emails. The 3 emails can be consumed independently (i.e., vision system utilization, concentrate control system utilization, and inspection utilization) or collectively (e.g., leading indicators). I feel that the collective output would benefit the end customer (supervisors) better than 3 emails and also limit the which one is more important question. Now to my inquiry, each of the three sends an output of last day use by line by shift, MTD by line by shift and YTD by line by shift. This is done by collecting data, appending to an Excel file, analyzing the data set, and exporting the new summaries (daily, MTD and YTD). Would Python Subprocess Module be a good tool to use for these three scripts, collect their output and then merge the three outputs into one email? Would this open me up to any security issues? Pros and cons? submitted by /u/bmille49 [link] [comments] 

Hey y’all! New to Python and have existing scripts (9) that run separately, are independent of one another, and 3 of them send emails. The 3 emails can be consumed independently (i.e., vision system utilization, concentrate control system utilization, and inspection utilization) or collectively (e.g., leading indicators). I feel that the collective output would benefit the end customer (supervisors) better than 3 emails and also limit the which one is more important question.

Now to my inquiry, each of the three sends an output of last day use by line by shift, MTD by line by shift and YTD by line by shift. This is done by collecting data, appending to an Excel file, analyzing the data set, and exporting the new summaries (daily, MTD and YTD). Would Python Subprocess Module be a good tool to use for these three scripts, collect their output and then merge the three outputs into one email? Would this open me up to any security issues? Pros and cons?

submitted by /u/bmille49
[link] [comments]  Hey y’all! New to Python and have existing scripts (9) that run separately, are independent of one another, and 3 of them send emails. The 3 emails can be consumed independently (i.e., vision system utilization, concentrate control system utilization, and inspection utilization) or collectively (e.g., leading indicators). I feel that the collective output would benefit the end customer (supervisors) better than 3 emails and also limit the which one is more important question. Now to my inquiry, each of the three sends an output of last day use by line by shift, MTD by line by shift and YTD by line by shift. This is done by collecting data, appending to an Excel file, analyzing the data set, and exporting the new summaries (daily, MTD and YTD). Would Python Subprocess Module be a good tool to use for these three scripts, collect their output and then merge the three outputs into one email? Would this open me up to any security issues? Pros and cons? submitted by /u/bmille49 [link] [comments]

Read more