I am importing the CSV file from here: https://raw.githubusercontent.com/kwartler/Harvard_DataMining_Business_Student/master/BookDataSets/LaptopSales.csv
This code works:
from dfply import *
import pandas as pd
df = pd.read_csv("LaptopSales.csv")
(df >> select(X["Date"]) >> mutate(AdjDate = (X.Date.str.split(" "))) >> head(3))
and produces this result:
Date AdjDate
0 01-01-2008 00:01 [01-01-2008, 00:01]
1 01-01-2008 00:02 [01-01-2008, 00:02]
2 01-01-2008 00:04 [01-01-2008, 00:04]
But when I try to extract the first element in the list:
from dfply import *
import pandas as pd
df = pd.read_csv("LaptopSales.csv")
(df >> select(X["Date"]) >> mutate(AdjDate = (X.Date.str.split(" ")[0])) >> head(3))
I get a wall of error culminating in:
ValueError: Length of values (2) does not match length of index (279999)