<jupyter_start><jupyter_text>Ex3 - Getting and Knowing your Data This time we are going to pull data directly from the internet.Special thanks to: https://github.com/justmarkham for sharing the dataset and materials. Step 1. Import the necessary libraries<jupyter_code>import pandas as pd<jupyter_output><empty_output><jupyter_text>Step 2. Import the dataset from this [address](https://raw.githubusercontent.com/justmarkham/DAT8/master/data/u.user).<jupyter_code>url = 'https://raw.githubusercontent.com/justmarkham/DAT8/master/data/u.user'<jupyter_output><empty_output><jupyter_text>Step 3. Assign it to a variable called users and use the 'user_id' as index<jupyter_code>df = pd.read_csv(url, sep = '|')
df.set_index ('user_id')<jupyter_output><empty_output><jupyter_text>Step 4. See the first 25 entries<jupyter_code>df.head (25)<jupyter_output><empty_output><jupyter_text>Step 5. See the last 10 entries<jupyter_code>df.tail (10)<jupyter_output><empty_output><jupyter_text>Step 6. What is the number of observations in the dataset?<jupyter_code>len (df)
df.shape<jupyter_output><empty_output><jupyter_text>Step 7. What is the number of columns in the dataset?<jupyter_code>len (df.columns)<jupyter_output><empty_output><jupyter_text>Step 8. Print the name of all the columns.<jupyter_code>print (df.columns)<jupyter_output>Index(['user_id', 'age', 'gender', 'occupation', 'zip_code'], dtype='object')<jupyter_text>[ ]  Step 9. How is the dataset indexed?  Step 10. What is the data type of each column?<jupyter_code>### he probado con class pero no ha funcionado
class (df.columns)
##no es exaxtamante lo que buscoi, pero me vale
type(df)
df.dtypes<jupyter_output><empty_output><jupyter_text>Step 11. Print only the occupation column<jupyter_code>df
df.occupation
df.keys()
dic = {
    'nombres': ['´pepa', '´maria'],
    '´peso': [34,35]
}
dic
dic.keys()
dic.values()
dic.items()
df.keys()
df.columns<jupyter_output><empty_output><jupyter_text>Step 12. How many different occupations are in this dataset?<jupyter_code>df.occupation.value_counts().count()
df.occupation.unique()
df.occupation.unique().shape<jupyter_output><empty_output><jupyter_text>Step 13. What is the most frequent occupation?<jupyter_code>df.occupation.value_counts()[:1]<jupyter_output><empty_output><jupyter_text>Step 14. Summarize the DataFrame.<jupyter_code>df.sum()
df.info ()
df.describe()<jupyter_output><empty_output><jupyter_text>Step 15. Summarize all the columns<jupyter_code>df.describe(include='all')<jupyter_output><empty_output><jupyter_text>Step 16. Summarize only the occupation column<jupyter_code>df.occupation.describe(include='all')
df.occupation.describe()<jupyter_output><empty_output><jupyter_text>Step 17. What is the mean age of users?<jupyter_code>df.age.mean()<jupyter_output><empty_output><jupyter_text>Step 18. What is the age with least occurrence?<jupyter_code>##con esto me dice el total de edades que hay, pero no sé cómo sacar la menor
df.age.value_counts().tail()
df.age.value_counts ().count ()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1250822909809085, 'fraction_numerical': 0.014154048716260697, 'mean_word_length': 7.609065155807365, 'pattern_counts': {'":': 0, '<': 68, '<?xml version=': 0, '>': 68, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '17', 'dir': 'jupyter-structured-clean-dedup', 'id': '305576', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1095, 'n_words': 243, 'path': '01_Getting_&_Knowing_Your_Data/Occupation/Exercises.ipynb', 'repo_name': 'iamoespana92/pandas_exercises', 'size': '3038'}