For a test to understand and be able to change format as I desire..tried the following code:
df = pd.DataFrame(['07/14/2009 00:00', '07/14/2009 00:30'])
pd.to_datetime(df,format=%Y%m%d)
This format is exactly as in this link
Yet on my mac terminal it returned the AttributeError on %Y. How may I understand this and resolve it? Kindly let me know :(
Your df variable looks like it should be a Series instead of a DataFrame from what I could tell in that link. Your format also does not match up with the format of your variable.
Related
Putting on my dunce cap because I'm sure the answer will be simple but for the life if me I can't get this to work. I need to convert the numeric date to display as follows "20200412" to try and match between another data set.
I've tried this:
Newdate=put (old date, yymmdd8.); and it just makes new date display as blank.
Thanks for any help.
Just use newDate=input(oldDate, YYMMDDN.); instead.
data test;
oldDate="20220412";
format newDate YYMMDDN.;
newDate=input(oldDate, YYMMDDN.);
run;
This format is what you want.
My preceding module in Integromat gives me an expiration date in UNIX time, which is 1640930400.
When I use the FormatDate function to convert this, I'm getting 12/31/1969 when I was expecting to get 12/31/2021. I can't seem to figure out what I'm doing wrong here. Any help would be much appreciated.
Use this instead to first parse the date and then apply the desired formatting to get the results that you want,
{{formatDate(parseDate(1.date; "X"); "MM/DD/YYYY")}}
I have a DateTime variable (default formatting), and I would like to format it to a format to I receive from a string parameter.
I normally do something similar to: {myDate:yyyy-MM-dd}, and it works properly.
Now I have a lot of possible date formats and need to format according to the chosen one.
I have tried the following but returned garbage (ae0aor0aa):
string testFormat = "yyyy. MM. dd.";
{myDate:testFormat }
I have also tried to convert the date to string and back to date with ParseExact, but gave me an invalid date exception. NB: the date in myDate is valid, as I have checked it with the debugger.
Can you kindly advise?
Thanks to apc, it was easily solved by myDate.ToString(testFormat)
I'm trying to export a Julia dataframe into a CSV and it contains nothing values. To simiplify let's say I have the following dataframe:
using DataFrames, CSV
df = DataFrame(A = [nothing,2,3], B = [4,5,nothing])
When I try to export, I get the following error:
df |> CSV.write("df.csv")
ArgumentError: `nothing` should not be printed; use `show`, `repr`, or custom output instead.
Should I convert the nothing values to something else like missing? If so, how would I code this?
You can use something function to convert nothing to whatever you want (e.g. missing) like this:
something.(df, missing) |> CSV.write("aaa.txt")
The current reasoning behind the design not to support nothing when writing a CSV file is given here.
I prefer the syntax of the CSV transform argument:
CSV.write("filename.csv", df, transform=(col, val) -> something(val, missing))
From the CSV.write documentation
Posting this as a separate answer, hopefully to distinguish comments and gather clarifications if I am missing something important.
I am currently writing a block of code on R which collects data via a SPARQL query. My problem is when I am trying to filter the query by date, R gives an error of "unexpected numeric constant".
There is no any mistake in the SPARQL code because when I run the exact code on the endpoint I receive data normally.
You will find the block of code where I have the problem. It does not matter the lines before and after, just the second line of the date filter.
...
OPTIONAL {?seller gr:legalName ?sellerLegalName} .
FILTER REGEX (STR(?date) >= "2015-01-01") .
FILTER NOT EXISTS {?spendingItem elod:hasCorrectedDecision ?correctedDecision} .
...
Please, I would kindly ask for your help! :)
For any further information that you want in order to solve the problem, feel free to contact with me.
Thank you all!!!
SOLVED!
I found that the date should be passed as timestamp!
Also, I found a useful site where you can convert any date in timestamp and vice versa.
I would like to thank you all for your responses and your useful help!
You should filter it as a date/time value rather than as a string - perhaps that will help:
FILTER (?date > "2015-01-01"^^xsd:date)
See this answer: SPARQL date range