Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Index constructor take Series or Index objects. #2071

Merged
merged 5 commits into from
Mar 2, 2021

Conversation

ueshin
Copy link
Collaborator

@ueshin ueshin commented Mar 1, 2021

Makes Index constructor take Series or Index objects.

>>> kser = ks.Series([1, 2, 3], name="a", index=[10, 20, 30])
>>> ks.Index(kser)
Int64Index([1, 2, 3], dtype='int64', name='a')
>>> ks.Int64Index(kser)
Int64Index([1, 2, 3], dtype='int64', name='a')
>>> ks.Float64Index(kser)
Float64Index([1.0, 2.0, 3.0], dtype='float64', name='a')

>>> kser = ks.Series([datetime(2021, 3, 1), datetime(2021, 3, 2)], index=[10, 20])
>>> ks.Index(kser)
DatetimeIndex(['2021-03-01', '2021-03-02'], dtype='datetime64[ns]', freq=None)
>>> ks.DatetimeIndex(kser)
DatetimeIndex(['2021-03-01', '2021-03-02'], dtype='datetime64[ns]', freq=None)

@ueshin ueshin requested a review from xinrong-meng March 1, 2021 22:27
@xinrong-meng
Copy link
Contributor

Looks great, thank you!

@codecov-io
Copy link

codecov-io commented Mar 1, 2021

Codecov Report

Merging #2071 (6dc9e9f) into master (0f6eb80) will decrease coverage by 0.14%.
The diff coverage is 96.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2071      +/-   ##
==========================================
- Coverage   94.68%   94.53%   -0.15%     
==========================================
  Files          55       55              
  Lines       11718    11747      +29     
==========================================
+ Hits        11095    11105      +10     
- Misses        623      642      +19     
Impacted Files Coverage Δ
databricks/koalas/indexes/base.py 97.29% <93.33%> (-0.12%) ⬇️
databricks/koalas/base.py 97.53% <100.00%> (ø)
databricks/koalas/indexes/datetimes.py 92.85% <100.00%> (+1.55%) ⬆️
databricks/koalas/indexes/numeric.py 92.59% <100.00%> (+3.70%) ⬆️
databricks/koalas/typedef/typehints.py 91.62% <0.00%> (-2.80%) ⬇️
databricks/koalas/__init__.py 89.33% <0.00%> (-2.67%) ⬇️
databricks/conftest.py 98.55% <0.00%> (-1.45%) ⬇️
databricks/koalas/plot/matplotlib.py 91.63% <0.00%> (-0.37%) ⬇️
databricks/koalas/indexes/multi.py 93.47% <0.00%> (-0.35%) ⬇️
databricks/koalas/generic.py 93.03% <0.00%> (-0.22%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f6eb80...6622d2a. Read the comment docs.

@ueshin
Copy link
Collaborator Author

ueshin commented Mar 2, 2021

Thanks! merging.

@ueshin ueshin merged commit f229f74 into databricks:master Mar 2, 2021
@ueshin ueshin deleted the index branch March 2, 2021 00:23
@@ -81,12 +81,18 @@ class DatetimeIndex(Index):
>>> ks.DatetimeIndex(['1970-01-01', '1970-01-01', '1970-01-01'])
DatetimeIndex(['1970-01-01', '1970-01-01', '1970-01-01'], dtype='datetime64[ns]', freq=None)

From a Seires:
From a Series:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great catch! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants