<jupyter_start><jupyter_text>DataFrame Basics Tutorial  **Dataframe is most commonly used object in pandas. It is a table like datastructure containing rows and columns similar to excel spreadsheet**<jupyter_code>import pandas as pd
weather_data = {
    'day': ['1/1/2017','1/2/2017','1/3/2017','1/4/2017','1/5/2017','1/6/2017'],
    'temperature': [32,35,28,24,32,31],
    'windspeed': [6,7,2,7,4,2],
    'event': ['Rain', 'Sunny', 'Snow','Snow','Rain', 'Sunny']
}
df = pd.DataFrame(weather_data)
df = pd.read_csv("weather_data.csv")
df
df.shape # rows, columns = df.shape<jupyter_output><empty_output><jupyter_text>Rows<jupyter_code>df.head() # df.head(3)
df.tail() # df.tail(2)
df[1:3]<jupyter_output><empty_output><jupyter_text>Columns<jupyter_code>df.columns
df['day'] # or df.day
type(df['day'])
df[['day','temperature']]<jupyter_output><empty_output><jupyter_text>Operations On DataFrame<jupyter_code>df['temperature'].max()
df[df['temperature']>32]
df['day'][df['temperature'] == df['temperature'].max()] # Kinda doing SQL in pandas
df[df['temperature'] == df['temperature'].max()] # Kinda doing SQL in pandas
df['temperature'].std()
df['event'].max() # But mean() won't work since data type is string
df.describe()<jupyter_output><empty_output><jupyter_text>**Google pandas series operations to find out list of all operations**http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.html  set_index<jupyter_code>df.set_index('day')
df.set_index('day', inplace=True)
df
df.index
df.loc['1/2/2017']
df.reset_index(inplace=True)
df.head()
df.set_index('event',inplace=True) # this is kind of building a hash map using event as a key
df
df.loc['Snow']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18304885226603884, 'fraction_numerical': 0.03884638022366098, 'mean_word_length': 7.252427184466019, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '539510', 'license': 'MIT', 'n_tokens_mistral': 680, 'n_tokens_neox': 630, 'n_words': 121, 'path': "Program's_Contributed_By_Contributors/AI-Summer-Course/py-master/pandas/2_dataframe_basics/dataframe_basics.ipynb", 'repo_name': 'siddharthdeo99/Hacktoberfest2k21', 'size': '1699'}