You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm stuck. I used the following to fill in Nan values:
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.feature_selection import f_regression
from sklearn.metrics import mean_squared_error, mean_absolute_error
%pylab inline
male = titanic[titanic['sex'] == "male"]
female = titanic[titanic['sex'] == "female"]
male = male.fillna(male.mean())
female = female.fillna(male.mean())
Then I was able to graph the values using the following:
male['age'].hist()
female['age'].hist()
But when I use this method to graph, I am able to graph the male age population but I get an error for the female graph that reads: "KeyError: 0L"
Additionally, the reason why I'm filling in Nan values is because I couldn't graph the following: plt.hist(titanic['age'])
because I was getting an error message that stated: "AttributeError: max must be larger than min in range parameter."
Thanks!
The text was updated successfully, but these errors were encountered:
Hi, I'm stuck. I used the following to fill in Nan values:
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.feature_selection import f_regression
from sklearn.metrics import mean_squared_error, mean_absolute_error
%pylab inline
male = titanic[titanic['sex'] == "male"]
female = titanic[titanic['sex'] == "female"]
male = male.fillna(male.mean())
female = female.fillna(male.mean())
Then I was able to graph the values using the following:
male['age'].hist()
female['age'].hist()
But when I use this method to graph, I am able to graph the male age population but I get an error for the female graph that reads: "KeyError: 0L"
fig = plt.figure()
fig.set_figwidth(20)
fig.set_figheight(8)
ax1 = fig.add_subplot(1,2,1)
ax1.hist(male['age'])
plt.title('Male Age')
plt.xlabel('Age')
plt.ylabel('Number of Occurences')
plt.grid(True)
ax2 = fig.add_subplot(1,2,2)
ax2.hist(female['age'])
plt.title('Female Age')
plt.xlabel('Age')
plt.ylabel('Number of Occurences')
plt.grid(True)
Can you please help!
Additionally, the reason why I'm filling in Nan values is because I couldn't graph the following: plt.hist(titanic['age'])
because I was getting an error message that stated: "AttributeError: max must be larger than min in range parameter."
Thanks!
The text was updated successfully, but these errors were encountered: