forked from mwaskom/seaborn-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflights.py
30 lines (24 loc) · 1.01 KB
/
flights.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import numpy as np
import pandas as pd
def main():
flights = pd.read_csv("/Users/mwaskom/Desktop/AirPassengers.csv")
flights["year"] = np.floor(flights.time).astype(int)
flights["month"] = np.round((flights.time - flights.year) * 12).astype(int)
month_number_to_name = {0: "January",
1: "February",
2: "March",
3: "April",
4: "May",
5: "June",
6: "July",
7: "August",
8: "September",
9: "October",
10: "November",
11: "December"}
flights["month"] = flights.month.map(month_number_to_name)
flights["passengers"] = flights["AirPassengers"]
flights = flights.drop(["AirPassengers", "time", "Unnamed: 0"], axis=1)
flights.to_csv("flights.csv", index=False)
if __name__ == "__main__":
main()