<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Help Converting Search Cursor to Pandas Read CSV? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/help-converting-search-cursor-to-pandas-read-csv/m-p/1593414#M73879</link>
    <description>&lt;P&gt;Need to learn Pandas.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;import&lt;/SPAN&gt; pandas &lt;SPAN class=""&gt;as&lt;/SPAN&gt; pd --I am just a newb here at esri. If I am wrong, someone, please tell me.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Mar 2025 17:02:09 GMT</pubDate>
    <dc:creator>AIYoda</dc:creator>
    <dc:date>2025-03-07T17:02:09Z</dc:date>
    <item>
      <title>Help Converting Search Cursor to Pandas Read CSV?</title>
      <link>https://community.esri.com/t5/python-questions/help-converting-search-cursor-to-pandas-read-csv/m-p/1593395#M73878</link>
      <description>&lt;P class=""&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;I'm currently using a search cursor to read data from a feature class in a Jupyter Notebook ArcGIS Pro. I'd like to migrate out of ArcGIS Pro and use a simple csv reader to return a value from a function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Basically, I need to loop through a list of locations ('Nodes'), and find the row for that location, then calculate the value of a function based on the values of other columns in that row.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;While I have a search cursor that works as intended, I'm unsure how to loop through the csv and reference the value of one column based on the value of another column.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;The search cursor looks like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;def Function2GetAValue(Node,Prop,Time):&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;fields = [LIST OF FIELDS HERE]&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;with arcpy.da.SearchCursor(f'FeatureClass{time},fields) as cursor:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;for row in cursor:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;if Node == row[0]:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Value = ((Prop+ row[1] + row[2]) * row[3])&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;return (round(Value,2))&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;What I'd like to have is something closer to this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;import pandas a pd&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;GETaValueFromFC = fr"PATHTOTHEFEATURECLASSTABLE{time}.csv" &lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;dfT=pd.read_csv(GETaValueFromFC) &lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;for index, row in dfT.iterrows(): &lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;if ['Node'] == currentNode:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;DM = ((Prop + row[COLUMname] + row[COLUMname]) * row[COLUMname]) &lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;return (round(float(VALUE),2))&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2025 17:15:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-converting-search-cursor-to-pandas-read-csv/m-p/1593395#M73878</guid>
      <dc:creator>Ashleigh_Price</dc:creator>
      <dc:date>2025-03-07T17:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help Converting Search Cursor to Pandas Read CSV?</title>
      <link>https://community.esri.com/t5/python-questions/help-converting-search-cursor-to-pandas-read-csv/m-p/1593414#M73879</link>
      <description>&lt;P&gt;Need to learn Pandas.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;import&lt;/SPAN&gt; pandas &lt;SPAN class=""&gt;as&lt;/SPAN&gt; pd --I am just a newb here at esri. If I am wrong, someone, please tell me.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2025 17:02:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-converting-search-cursor-to-pandas-read-csv/m-p/1593414#M73879</guid>
      <dc:creator>AIYoda</dc:creator>
      <dc:date>2025-03-07T17:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help Converting Search Cursor to Pandas Read CSV?</title>
      <link>https://community.esri.com/t5/python-questions/help-converting-search-cursor-to-pandas-read-csv/m-p/1593471#M73880</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/428854"&gt;@Ashleigh_Price&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pandas is a great tool to use for this, I use it extremely often, almost daily to this exact thing, here is your code rewritten:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import pandas as pd

def get_value_from_csv(node, prop, time):
    csv_path = fr"PATHTOTHEFEATURECLASSTABLE{time}.csv"

    df = pd.read_csv(csv_path)
   
    matching_row = df[df['Node'] == node]
    
    if not matching_row.empty:
        row = matching_row.iloc[0]

        value = ((prop + row['Column1'] + row['Column2']) * row['Column3'])
        
        return round(float(value), 2)
    else:
        return None

# Example:
# current_node = "some_node_value"
# property_value = 10
# time_period = "2025"
# result = get_value_from_csv(current_node, property_value, time_period)&lt;/LI-CODE&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2025 17:47:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-converting-search-cursor-to-pandas-read-csv/m-p/1593471#M73880</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2025-03-07T17:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help Converting Search Cursor to Pandas Read CSV?</title>
      <link>https://community.esri.com/t5/python-questions/help-converting-search-cursor-to-pandas-read-csv/m-p/1593618#M73887</link>
      <description>&lt;P&gt;Solved! This works just like the search cursor (and is much faster).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 08 Mar 2025 14:09:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-converting-search-cursor-to-pandas-read-csv/m-p/1593618#M73887</guid>
      <dc:creator>Ashleigh_Price</dc:creator>
      <dc:date>2025-03-08T14:09:30Z</dc:date>
    </item>
  </channel>
</rss>

