<jupyter_start><jupyter_text>DataFramesDataFrames are the workhorse of pandas and are directly inspired by the R programming language.<jupyter_code>import pandas as pd
import numpy as np
from numpy.random import randn
np.random.seed(101)
df = pd.DataFrame(randn(5,4),index='A B C D E'.split(),columns='W X Y Z'.split())
df
df['W']
df[['W','Z']]
df[2:3]
type(df['W'])
df['nourdine'] = df['X'] * df['Y']
df
df.drop('nourdine', axis=1)
df
df = df.drop('nourdine', axis=1)
df
df['nourdine'] = df['X'] * df['Y']
df
df.drop('nourdine', axis=1, inplace=True)
df
df.drop('E',axis=0)
df
df.loc['A']
df.iloc[0]
df.loc['B','Y']
df>0
df[df['W']>0]
df[df['W']>0]['Y']
df[df['W']>0][['Y','X']]
df[(df['W']>0) & (df['Y'] > 1)]
df
df.reset_index()
newind = 'CA NY WY OR CO'.split()
newind
df['States'] = newind
df
df.set_index('States')
df
df.set_index('States', inplace=True)
df
df.describe()
df.dtypes
df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Index: 5 entries, CA to CO
Data columns (total 4 columns):
 #   Column  Non-Null Count  Dtype  
---  ------  --------------  -----  
 0   W       5 non-null      float64
 1   X       5 non-null      float64
 2   Y       5 non-null      float64
 3   Z       5 non-null      float64
dtypes: float64(4)
memory usage: 200.0+ bytes
{'fraction_non_alphanumeric': 0.21064996084573218, 'fraction_numerical': 0.033672670321064996, 'mean_word_length': 3.6472727272727274, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '599072', 'license': 'MIT', 'n_tokens_mistral': 553, 'n_tokens_neox': 529, 'n_words': 134, 'path': 'Pandas/02-DataFrames.ipynb', 'repo_name': 'mohamednourdine/PyTorch', 'size': '1277'}