WalidKhan Posted October 6, 2023 Posted October 6, 2023 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!
Sensei Posted October 6, 2023 Posted October 6, 2023 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....
Arthur Smith Posted October 6, 2023 Posted October 6, 2023 Also bear in mind the unconceived alternative. 😉
HelioCentric Posted May 4 Posted May 4 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now