<?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: Data Analysis with Python: Calculating Mean and Median in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/data-analysis-with-python-calculating-mean-and/m-p/1334843#M68827</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;you could use the statistics module.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import statistics

data = [12, 45, 67, 23, 41, 89, 34, 54, 21]

median = statistics.median(data)
mean = statistics.mean(data)

print(median)
print(mean)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;41
42.888888888888886&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Oct 2023 08:42:24 GMT</pubDate>
    <dc:creator>Sven_Harpering</dc:creator>
    <dc:date>2023-10-04T08:42:24Z</dc:date>
    <item>
      <title>Data Analysis with Python: Calculating Mean and Median</title>
      <link>https://community.esri.com/t5/python-questions/data-analysis-with-python-calculating-mean-and/m-p/1334839#M68826</link>
      <description>&lt;P&gt;I'm working on a data analysis project in Python and need to calculate both the mean and median of a dataset. I understand the basic concepts, but I'm looking for a Python code example that demonstrates how to do this efficiently.&lt;/P&gt;&lt;P&gt;Let's say I have a list of numbers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;data = [12, 45, 67, 23, 41, 89, 34, 54, 21]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to calculate both the mean and median of these numbers. Could you provide a Python code snippet that accomplishes this? Additionally, it would be helpful if you could explain any libraries or functions used in the code.&lt;/P&gt;&lt;P&gt;Thank you for your assistance in calculating these basic statistics for my data analysis project!&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 07:14:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-analysis-with-python-calculating-mean-and/m-p/1334839#M68826</guid>
      <dc:creator>hectorsalamanca</dc:creator>
      <dc:date>2023-10-04T07:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: Data Analysis with Python: Calculating Mean and Median</title>
      <link>https://community.esri.com/t5/python-questions/data-analysis-with-python-calculating-mean-and/m-p/1334843#M68827</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;you could use the statistics module.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import statistics

data = [12, 45, 67, 23, 41, 89, 34, 54, 21]

median = statistics.median(data)
mean = statistics.mean(data)

print(median)
print(mean)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;41
42.888888888888886&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 08:42:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-analysis-with-python-calculating-mean-and/m-p/1334843#M68827</guid>
      <dc:creator>Sven_Harpering</dc:creator>
      <dc:date>2023-10-04T08:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Data Analysis with Python: Calculating Mean and Median</title>
      <link>https://community.esri.com/t5/python-questions/data-analysis-with-python-calculating-mean-and/m-p/1334853#M68828</link>
      <description>&lt;P&gt;Or the numpy module&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import numpy as np

data = [12, 45, 67, 23, 41, 89, 34, 54, 21]
np.mean(data), np.median(data)
(42.888888888888886, 41.0)

or using the percentile
np.percentile(data, 50)
41.0&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 04 Oct 2023 09:18:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-analysis-with-python-calculating-mean-and/m-p/1334853#M68828</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-10-04T09:18:35Z</dc:date>
    </item>
  </channel>
</rss>

