I am working on the Cars.csv DataFrame which can be found here: https://www.kaggle.com/ljanjughazyan/cars1
My goal is to create a new Data Frame with the column names: USA, Europe and Japan and to save the number of cars that are in each category.
for a in list(cars.origin.unique()):
x= pd.DataFrame({a:[cars.loc[cars["origin"]==a,"origin"].size]})
I tried it with this code, but as a result I obtain a Data Frame with only one column that is "Europe". So it kind of works, but I cant figure why it just dismisses the other values. Why doesnt it work and can it be done using a for-loop?
Thanks in advance!!