420chan now has a web-based IRC client available, right here
Leave these fields empty (spam trap):
Name
You can leave this blank to post anonymously, or you can create a Tripcode by using the float Name#Password
Comment
[*]Italic Text[/*]
[**]Bold Text[/**]
[~]Taimapedia Article[/~]
[%]Spoiler Text[/%]
>Highlight/Quote Text
[pre]Preformatted & Monospace text[/pre]
1. Numbered lists become ordered lists
* Bulleted lists become unordered lists
File

Sandwich


Community Updates

420chan now supports HTTPS! If you find any issues, you may report them in this thread
python and you and me and you also by Lydia Cinnerkutch - Thu, 16 Feb 2017 16:17:09 EST ID:1UV84ceD No.36510 Ignore Report Quick Reply
File: 1487279829548.jpg -(3283017B / 3.13MB, 3840x2160) Thumbnail displayed, click image for full size. 3283017
Hi this forum was helpful with teaching me a pythonic way to do something before so I'm hoping you can share another pattern with me for a new problem I have.

Using pandas to merge two dataframes based on time series info how can I expand the values in one dataframe that is based on daily information to match the dataframe based on the minute. I have two time columns one in format day/month/year ti:me in ten minute intervals and the other is day/month/year. So sample data looks like:

Time - A - b
1/1/2017 00:00:10 - 5 - 6
1/1/2017 00:00:20 - 3 - 2
1/1/2017 00:00:30 - 4 - 4 etc
&& in the other dataframe I want to merge it is

Time - Value1 - Value2
1/1/2017 - 9 - 1
1/2/2017 - 5 - 6
So it should look like

Time - A - B - value1 - value2
1/1/2017 00:00:10 - 5 - 6 - 9 - 1
1/1/2017 00:00:20 - 3 - 2 - 9 - 1
1/1/2017 00:00:30 - 4 - 4 - 9 - 1
>>
Fanny Tillingfield - Sat, 18 Feb 2017 04:30:27 EST ID:dluvNLbx No.36513 Ignore Report Quick Reply
  1. Pandas isn't Python. The Pythonic solution involves a list comprehension and isn't what you want to do.
  2. Unless you're interested in the continuity of your date+timestamp value, I would split that permanently.
  3. Once you have a simple date column in each DF, what you're looking to do is merge: merged_df = df1.merge(df2, left_on='date', right_on='date', how='outer')
  4. 2017-01-01. That's how you'll format dates now. Forever.
>>
Phoebe Blemmlepire - Sat, 18 Feb 2017 04:41:18 EST ID:9QSfnS0r No.36514 Ignore Report Quick Reply
Why do store time/date in this fashion? Use unix timestamps and some library like dateutil to parse them.
I'd convert the time/date into timestamps the first chance I'd get then it's just a regular value and easy to deal with.
>>
Edwin Brondleforth - Tue, 21 Mar 2017 20:10:27 EST ID:JW2J65bb No.36630 Ignore Report Quick Reply
df1.merge(df2.reindex(index=df1.index, df1, method='pad'))


Report Post
Reason
Note
Please be descriptive with report notes,
this helps staff resolve issues quicker.