I am currently analyzing data with python's jupyter notebook.
I read the data group including the column in which the date was entered like "2018/12/31" in the csv file with the to_csv function. And I tried to convert that column to a separate row by year, month, and day, but it doesn't work. In particular
time = datetime.strptime (set ["date"], "% Y /% m /% d")
TypeError: strptime () argument 1 must be str, not Series
I got an error. I was able to speculate that the content of the error might mean that Series cannot be converted by strptime (), but I couldn't think of what means could be used instead.
Thanks for your answer.
Answer # 1
I read the data group including the column in which the date was entered like "2018/12/31" in the csv file with the to_csv function.
read_csvI wonder if it's okay to read it in.
to_csvIs for writing.
When reading, Optional arguments
parse_datesIf you specify the date column with, you will get a datetime64 [ns] type column with each element of type TimeStamp. The value delimiter
The rest is prepared for the dt accessor
dt.dayTake out each value using etc. and make a new column to complete.
df = pd.read_csv ('hogehoge.csv', parse_dates = ['date']) df ['year'] = df ['year/month/day'] .dt.year df ['month'] = df ['year/month/day'] .dt.month df ['day'] = df ['date']. dt.day print (df)
Answer # 2
And that column by year, month, date
I think you can get the year, month, and day below.
set ["year/month/day"] = pd.to_datetime (set ["year/month/day"]) set ["year"] = set ["year/month/day"] .dt.year set ["month"] = set ["year/month/day"] .dt.month set ["day"] = set ["year/month/day"] .dt.day
- how to convert a string to date type in python
- i want to convert "array string" to an array in python
- i want to extract specific information from a python string
- python - i made a code to search a website tag as a string, but can it be simplified?
- i want to extract the date and time from a string in python
- python - i want to convert the characters obtained from the txt file to numbers
- python - (tensorflow) please tell me how to convert any 28x28 image in the same way as the mnist image (pyrhon)
- [php] how to convert from character string to date type
- python fourier series the expanded formula is output to the graph
- i want to aggregate a specific character string by day using the python groupby count function etc
- python - sum of numbers by inputting a character string
- i want to extract one character string of text that exists in multiple files with python
- python - causality in time series data analysis
- (python) i want to convert multiple json files with different columns into one csv format
- perl - i want to convert the line feed part of a character string including a line feed to \ n and insert it with sed
- i want to change a string to hexadecimal in python
- python - i want to convert the histogram to a bar graph
- how to convert the array type of the value extracted by the condition specification from the python array to the integer type?
- python - i want to convert numeric data to time and process it
- "openpyxl" cannot be imported in python
- python - launch jupyterlab/notebook from the terminal
- python - something went wrong in the jupiter lab
- python 3x - i want to resolve the error typeerror: loop of ufunc does not support argument 0 of type float which has no callable
- python - modelpredict() cannot be executed in tensorflow
- macos (osx) - sort_valus method error macos
- please add a python error
- i'm trying to create a scientific calculator with jupyter's python, but i want to add exponentiation, factorial, function, log,
- python - missing 1 required positional argument error
- python 3x - i want to display the importance extracted by evaluating with random forest as a column graph