Pandas Hacks
- make your own data using your brian, google or chatgpt, should look different than mine.
- modify my code or write your own
- output your data other than a bar graph.
- answer the questions below, the more explained the better.
### Questions (0.9)
- What are the two primary data structures in pandas and how do they differ?
- The two primary data structures in pandas are CSV files and databases.
- How do you read a CSV file into a pandas DataFrame?
- To read a CSV file into a pandas DataFrame, you can use the read_csv function in pandas.
- How do you select a single column from a pandas DataFrame?
- To select a single column from a pandas DataFrame, you can use the indexing operator [] with the column name
- How do you filter rows in a pandas DataFrame based on a condition?
- To filter rows in a pandas DataFrame based on a condition, you can use boolean indexing.
- How do you group rows in a pandas DataFrame by a particular column?
- To group rows in a pandas DataFrame by a particular column, you can use the groupby method.
- How do you aggregate data in a pandas DataFrame using functions like sum and mean?
- To aggregate data in a pandas DataFrame using functions like sum and mean, you can use the agg method.
- How do you handle missing values in a pandas DataFrame?
- To handle missing values in a pandas DataFrame, you can use the fillna method to fill in missing values with a specific value or method, or you can use the dropna method to remove rows with missing values.
- How do you merge two pandas DataFrames together?
- To merge two pandas DataFrames together, you can use the merge method
- How do you export a pandas DataFrame to a CSV file?
- To export a pandas DataFrame to a CSV file, you can use the to_csv method
- What is the difference between a Series and a DataFrame in Pandas?
- The main difference between a Series and a DataFrame in pandas is that a Series is a one-dimensional array-like object, while a DataFrame is a two-dimensional table-like data structure. A Series can be thought of as a single column of a DataFrame, while a DataFrame can have multiple columns.