Simple code like this won't work anymore on my python shell:
import pandas as pd
df=pd.read_csv("K:/01. Personal/04. Models/10. Location/output.csv",index_col=None)
AttributeError: 'DataFrame' object has no attribute 'sample'
As given in the documentation of
DataFrame.sample(n=None, frac=None, replace=False, weights=None, random_state=None, axis=None)
Returns a random sample of items from an axis of object.
New in version 0.16.1.
DataFrame.sample is added in
0.16.1 , you can either -
pandas version to latest, you can use
pip for that, Example -
pip install pandas --upgrade
Or if you don't want to upgrade, and want to sample few rows from the dataframe, you can also use
random.sample(), Example -
import random num = 100 #number of samples sampleddata = df.loc[random.sample(list(df.index),num)]