<jupyter_start><jupyter_text>1. Overview of the Dataframe<jupyter_code>import pandas
from datetime import datetime
from pytz import utc
data = pandas.read_csv("reviews.csv", parse_dates= ["Timestamp"])
data.head()
data.shape
data.columns
data.hist("Rating")<jupyter_output><empty_output><jupyter_text>2. Selecting data from the dataframe  Selecting a column<jupyter_code>data["Rating"]<jupyter_output><empty_output><jupyter_text>Selecting multiple columns<jupyter_code>data[["Course Name", "Rating"]]<jupyter_output><empty_output><jupyter_text>Selecting a Row<jupyter_code>data.iloc[3]<jupyter_output><empty_output><jupyter_text>Selecting multiple rows<jupyter_code>data.iloc[1:3]<jupyter_output><empty_output><jupyter_text>Selecting a Cross Section<jupyter_code>data[["Course Name", "Rating"]].iloc[1:3]<jupyter_output><empty_output><jupyter_text>Selecting a particular cell<jupyter_code>data["Timestamp"].iloc[2]<jupyter_output><empty_output><jupyter_text>3. Filtering Data Based On Conditions  One Condition<jupyter_code>data[data["Rating"] > 4]
len(data[data["Rating"] > 4])
data[data["Rating"] > 4].count()
ratingFiltered = data[data["Rating"] > 4]
ratingFiltered["Rating"]
ratingFiltered["Rating"].mean()<jupyter_output><empty_output><jupyter_text>Multiple conditions<jupyter_code>data[( data["Rating"] > 4 ) & (data["Course Name"] == "Python for Beginners with Examples")]
dualCondition = data[( data["Rating"] > 4 ) & (data["Course Name"] == "Python for Beginners with Examples")]
dualCondition["Rating"].mean()<jupyter_output><empty_output><jupyter_text>4. Time Based Filtering<jupyter_code>data[ (data["Timestamp"] >= datetime(2020,7,1, tzinfo =utc)) & (data["Timestamp"] <= datetime(2020,12,31, tzinfo = utc)) ]
# You need to parse the dataframe Timestamp columns as dates and interpret the datetime ranges with the same Timezone
# as the Timestamps<jupyter_output><empty_output><jupyter_text>5. From data to information  Average of Rating of All Courses<jupyter_code>data["Rating"].mean()<jupyter_output><empty_output><jupyter_text>Average Rating for a particular course<jupyter_code>data[(data["Course Name"] == "Python for Beginners with Examples")]["Rating"].mean()<jupyter_output><empty_output><jupyter_text>Average Rating for a particular period<jupyter_code>data[ (data["Timestamp"] >= datetime(2020,7,1, tzinfo =utc)) & (data["Timestamp"] <= datetime(2020,12,31, tzinfo = utc)) ]["Rating"].mean()<jupyter_output><empty_output><jupyter_text>Average Rating for a particular course and period<jupyter_code>df1 = data[ (data["Timestamp"] >= datetime(2020,7,1, tzinfo =utc)) & (data["Timestamp"] <= datetime(2020,12,31, tzinfo = utc))]
df1[df1["Course Name"] == "Python for Beginners with Examples"]["Rating"].mean()<jupyter_output><empty_output><jupyter_text>Average of Commented Ratings<jupyter_code>data[data["Comment"].isnull()]["Rating"].mean()<jupyter_output><empty_output><jupyter_text>Average of Commented Ratings<jupyter_code>data[data["Comment"].notnull()]["Rating"].mean()<jupyter_output><empty_output><jupyter_text>Number of Uncommented Ratings<jupyter_code>data[data["Comment"].isnull()]["Rating"].count()<jupyter_output><empty_output><jupyter_text>Number of Commented Ratings<jupyter_code>data[data["Comment"].notnull()]["Rating"].count()<jupyter_output><empty_output><jupyter_text>Number of Comments Containing a Certain Word<jupyter_code>data[(data["Comment"].str.contains("accent", na = False))]["Comment"].count()
data[(data["Comment"].str.contains("accent", na = False))]["Rating"].mean()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1607997747113489, 'fraction_numerical': 0.017459870459025625, 'mean_word_length': 12.010989010989011, 'pattern_counts': {'":': 0, '<': 80, '<?xml version=': 0, '>': 86, 'https://': 0, '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': '19', 'dir': 'jupyter-structured-clean-dedup', 'id': '499718', 'license': 'MIT', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1214, 'n_words': 199, 'path': '04. Data Analysis/review_analysis/reviews.ipynb', 'repo_name': 'lior-abadi/python-training', 'size': '3551'}