I'm working on an NBA Project and I am using an API to get data from Basketball Reference. The data type "SEASONS" with the dataframe shown below is as a date time object and I want to change it to a String but I'm unable to. What Am i doing wrong? Code is below. Data Frame with Seasons column
player["SEASON"]=player["SEASON"].values.astype('str')
line_graph = px.bar(data_frame=player, x='SEASON', y="PTS")
despite doing this my graph still looks like this graph showing it may be in a date time format. Can anyone please help?
If your SEASON column is a pandas datetime object, you can use the .dt.strftime() method:
player["SEASON"]=player["SEASON"].dt.strftime('%Y-%m')
line_graph = px.bar(data_frame=player, x='SEASON', y="PTS")