Attempting to derive the mean, median and mode from the dataframe. I need to know how to code the source in the function instead of ":".
source = [df.'DMC]
import pandas as pd
import nltk
df.head(4)
# This is the print out of the dataframe
# When I came up with this code, the source was
# source=[3,4,6,4,7,2,6,7,...]
# But now I need to get the data from a dataFrame.
# X Y month day DMC RH
# 0 7 5 3 fri 26.2 94.3
# 1 7 4 10 tue 90.6 35.4
# 2 6 6 12 mon 56.8 99.2
# this is just a sample
#This is the code to find the mean median and mode
source = [df:'DMC'] #This is were I need your help.
def meanmedianmode (source):
mmm = {'mean': Mean(source), 'median': Median(source), 'mode':
Mode(source) }
def Mean (source):
mean = reduce(lambda x,y: x+y, numbers)/len(source)
return mean
def Median(source):
median = numpy.median(source)
return(median)
def Mode (source):
mode = statistics.mode(source)
return mode
return mmm
print("mean median mode" + str(meanmedianmode(source)))