Exploring Ebay Car Sale Data GP - step6/9

Hello everyone,

I am stuck with the bay Car Sales GP. And I am struck at probably the most simple step - removing the rows (step 6 of 9). I cannot remove the rows that contain data for car sales with registration year before 1986 and after 2016. I tried several ways:

  1. I used boolean masks and .drop() method
  2. I have also tried using .delete() method, again with the boolean mask, no luck

Screen Link:

https://app.dataquest.io/m/294/guided-project%3A-exploring-ebay-car-sales-data/6/dealing-with-incorrect-registration-year-data

My Code:

1st try: autos[(autos['registration_year'] < 1986)].drop()

2nd try: autos[autos['registration_year'] < 1986].delete()



Replace this line with your code

What I expected to happen:

What actually happened:

ValueError: Need to specify at least one of 'labels', 'index' or 'columns'


Replace this line with the output/error

Can anybody give me a hint on what am I missing here? Thanks!

Did you mean After 1986 and before 2016??

There are many ways to achieve this.

  1. using Series.between this will return boolean Series equivalent to left <= series <= right.
autos = autos[autos["registration_year"].between(1986, 2016)]
  1. Logical Condition
autos = autos[(autos["registration_year"]>=1986)& (autos["registration_year"]<=2016)]

Continue learning:

2 Likes

Is there a way to see/print the values for 1969 to 1986? When I enter the code:
print(autos_c["registration_year"].value_counts(normalize= True).sort_index(ascending=True))
it shows for 1910 to 2016, except 1969 to 1986 is …, since it a long data set.

Output
1910 0.000107
1927 0.000021
1929 0.000021
1931 0.000021
1934 0.000043
1937 0.000086
1938 0.000021
1939 0.000021
1941 0.000043
1943 0.000021
1948 0.000021
1950 0.000064
1951 0.000043
1952 0.000021
1953 0.000021
1954 0.000043
1955 0.000043
1956 0.000086
1957 0.000043
1958 0.000086
1959 0.000129
1960 0.000514
1961 0.000129
1962 0.000086
1963 0.000171
1964 0.000257
1965 0.000364
1966 0.000471
1967 0.000557
1968 0.000557

1987 0.001542
1988 0.002891
1989 0.003727
1990 0.007432
1991 0.007260
1992 0.007946
1993 0.009102
1994 0.013471
1995 0.026300
1996 0.029405
1997 0.041784
1998 0.050608
1999 0.062066
2000 0.067592
2001 0.056476
2002 0.053243
2003 0.057804
2004 0.057890
2005 0.062880
2006 0.057205
2007 0.048766
2008 0.047439
2009 0.044676
2010 0.034032
2011 0.034760
2012 0.028056
2013 0.017198
2014 0.014221
2015 0.008395
2016 0.026129
Name: registration_year, Length: 78, dtype: float64