<jupyter_start><jupyter_text>Pandas pandas is one of the world's most popular Python library, used for everything from data manipulation to data analysis. pandas is used for **tabular data** (data which has rows and columns)  What can pandas do for us? - Load Tabular Data - Search For Particular rows and columns- Calculate all kinds of statistical methods.-  Combine data from multiple sources Run the following cell:<jupyter_code>!pip3 install pandas<jupyter_output><empty_output><jupyter_text>**Importing pandas:**<jupyter_code>import pandas as pd<jupyter_output><empty_output><jupyter_text>**How do I load a CSV file using pandas?** Let's mess around with a **Spotify** Dataset.<jupyter_code>df = pd.read_csv("top50.csv")
#CSV : Comma-separated values<jupyter_output><empty_output><jupyter_text>**Viewing df**<jupyter_code>df<jupyter_output><empty_output><jupyter_text>**Inspecting df**<jupyter_code>df.head()
df.info()<jupyter_output><empty_output><jupyter_text>Selecting Data   Subsetting A Column<jupyter_code>df['Genre']<jupyter_output><empty_output><jupyter_text>Subsetting multiple columns<jupyter_code>df[['Genre', 'Energy']].head()<jupyter_output><empty_output><jupyter_text>- The `.loc` operator Although selecting data with `[]` works, it's not necessarily the best way. Pandas' official documentation : >The Python and NumPy indexing operators [] and attribute operator . provide quick and easy access to pandas data structures across a wide range of use cases. This makes interactive work intuitive, as there’s little new to learn if you already know how to deal with Python dictionaries and NumPy arrays. However, since the type of the data to be accessed isn’t known in advance, directly using standard operators has some optimization limits. For production code, we recommended that you take advantage of the optimized pandas data access methods exposed in this chapter.<jupyter_code># select a row
df.loc[12]
# select a cell
df.loc[12, 'Track.Name']
#select a column
df.loc[:, 'Track.Name'].head()<jupyter_output><empty_output><jupyter_text>Remeber how we could perform slicing on lists? We can do the same thing with `.loc`!<jupyter_code># rows with label 2 to 5
df.loc[10:15]
# columns between Track.Name and Genre
df.loc[:, 'Track.Name':'Genre'].head()<jupyter_output><empty_output><jupyter_text>✨**Task** - Open `tweets.csv` using pandas into a dataframe called `new`. - Inspect the dataset.- Research how you can drop the NaN values. - Select the `text` column.- Select the 100th row using `.loc`- Select the cell on the 29th row on the **text** column.<jupyter_code>#INSERT YOUR CODE HERE<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09943289224952741, 'fraction_numerical': 0.006805293005671078, 'mean_word_length': 6.453521126760563, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 42, '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': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '529430', 'license': 'CC0-1.0', 'n_tokens_mistral': 836, 'n_tokens_neox': 798, 'n_words': 292, 'path': 'week-3/pandas & data viz/pandas.ipynb', 'repo_name': 'JungleProgram/python-essentials', 'size': '2645'}