This is the solution of pandas course (Creating, Reading and Writing) on Kaggle site.
Setup
import pandas as pd
1. Create a DataFrame
fruits = pd.DataFrame(
{"Apples": [30], "Bananas": [21]}
)
2. Create a DataFrame with Index
fruit_sales = pd.DataFrame(
{"Apples": [35, 41], "Bananas": [21, 34]}, index=["2017 Sales", "2018 Sales"]
)
3. Create a Series
ingredients = pd.Series(
["4 cups", "1 cup", "2 large", "1 can"],
index=[
"Flour",
"Milk",
"Eggs",
"Spam",
],
name="Dinner",
)
4. Create a DataFrame by Reading CSV File
reviews = pd.read_csv(
"../input/wine-reviews/winemag-data_first150k.csv",
index_col=0
)
5. Save DataFrame to CSV File
animals.to_csv("cows_and_goats.csv")
'Python' 카테고리의 다른 글
[Python] Pandas Course on Kaggle - 3 (0) | 2022.01.19 |
---|---|
[Python] Pandas Course on Kaggle - 2 (0) | 2022.01.17 |
[Python] finterstellar를 사용하여 Stochastic으로 주식 매매 시그널 만들기 (2) | 2021.12.14 |
[Python] finterstellar를 사용하여 Bollinger Band로 주식 매매 시그널 만들기 (0) | 2021.12.12 |
[Python] finterstellar를 사용하여 Envelope로 주식 매매 시그널 만들기 (0) | 2021.12.11 |
댓글