Jump to content

Recommended Posts

Posted

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.

Let's say I have a list of numbers:

data = [12, 45, 67, 23, 41, 89, 34, 54, 21]

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.

Thank you for your assistance in calculating these basic statistics for my data analysis project!

Posted
28 minutes ago, WalidKhan said:

I'm working on..

No, you do not work..

 

32 minutes ago, WalidKhan said:

but I'm looking for a Python code example that demonstrates how to do this efficiently.

...then show your not optimal code....

 

  • 6 months later...
Posted

All of the data analysis stuff in Python begins with the numpy library. Use numpy.mean() and numpy.median() after casting your list to a numpy.array like so:

Data = numpy.array([1,2,3])

Honestly the best advice though is use chatGPT for little coding questions like this.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.